#include <bits/stdc++.h>
using namespace std;
map<long long, int> s;
bool t[1001][1001];
int tt[1001];
long long a[1001], i, j, n, k, Max, x, length;
int Long(int x, int y) {
  t[x][y] = true;
  tt[x]--;
  tt[y]--;
  int i = x;
  int j = y;
  int k = s[a[i] + a[j]];
  int ans = 2;
  while (k && tt[k]) {
    ans++;
    i = j;
    j = k;
    tt[k]--;
    k = s[a[i] + a[j]];
    t[i][j] = true;
  }
  i = x;
  j = y;
  k = s[a[j] - a[i]];
  while (k && tt[k]) {
    ans++;
    tt[k]--;
    j = i;
    i = k;
    k = s[a[j] - a[i]];
    t[i][j] = true;
  }
  int sum = ans;
  k = s[a[i] + a[j]];
  while (ans > 0) {
    ans--;
    tt[i]++;
    i = j;
    j = k;
    k = s[a[i] + a[j]];
  }
  return sum;
}
int main() {
  scanf("%I64d", &n);
  for (i = 0; i < n; i++) {
    scanf("%I64d", &x);
    if (!s[x]) {
      s[x] = ++length;
      a[length] = x;
    }
    tt[s[x]]++;
  }
  for (i = 1; i <= length; i++) {
    for (j = 1; j <= length; j++)
      if (!t[i][j]) {
        if (i == j && tt[i] < 2)
          k = 0;
        else
          k = Long(i, j);
        if (k > Max) Max = k;
      }
  }
  printf("%d\n", Max);
  return 0;
}
