int amicableNumbers(int n) {
boolean found = false;
int i = Math.max(n, 200);
while (!found) {
int di = d(i);
int dj = d(di);
if (dj == i && di != i) {
found = true;
return i;
}
i++;
}
return -1;
}
int d(int n) {
int res = 1;
for (int i = 2; i < n; i++) if (n % i == 0) res+=i;
return res;
}