function solve() {
let lengths = [];
for (let a1 = 1; a1 < 100; a1++) {
for (let a2 = a1 + 1, isGood = true; a2 <= 100; a2++, isGood = true) {
for (let x = 1; x <= 100; x++) {
if (!f(a1, a2, x)) {
isGood = false;
break;
}
}
if (isGood) lengths.push(a2 - a1);
}
}
return Math.max(...lengths);
}