Const
auto = false;
var
soldier: array[1..5000]of integer;
n, i, j, k, max, t, d, imax, a, c: integer;
begin
if auto then begin
n := random(5000);
for i := 1 to n do
soldier[i] := random(5000);
end
else begin
readln(n);
for i := 1 to n do
read(soldier[i]);
end;
{сортирововчка}
for i := 1 to n - 1 do
begin
imax := i;
for j := i + 1 to n do
if soldier[j] > soldier[imax] then
imax := j;
max := soldier[i];
soldier[i] := soldier[imax];
soldier[imax] := max;
end;
max := 0;
for i := 1 to n - 1 do
for j := i + 1 to n do
begin
a := soldier[j];
d := soldier[j] - soldier[i];
c := 2;
for k := j + 1 to n do
if soldier[k] = a + d then begin
a := soldier[k];
c := c + 1;
end;
if c > max then max := c;
end;
writeln(max);
end.