#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 + 10;
int a[MAXN];
int n;
map<int, int> mp;
int dfs(int a, int b) {
  int ans = 0;
  if (mp[a + b]) {
    mp[a + b]--;
    ans = max(ans, dfs(b, a + b));
    mp[a + b]++;
  }
  return ans + 1;
}
int main() {
  scanf("%d", &n);
  mp.clear();
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    mp[a[i]]++;
  }
  sort(a + 1, a + n + 1);
  int m = unique(a + 1, a + n + 1) - a - 1;
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= m; j++) {
      if (i == j && mp[a[i]] == 1) continue;
      mp[a[i]]--;
      mp[a[j]]--;
      ans = max(ans, dfs(a[i], a[j]) + 1);
      mp[a[i]]++;
      mp[a[j]]++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
