#include <bits/stdc++.h>
using namespace std;
int num[1010];
map<int, int> fp;
int DFS(int a, int b) {
  int ans = 0;
  if (fp[a + b]) {
    fp[a + b]--;
    ans = DFS(b, a + b) + 1;
    fp[a + b]++;
  }
  return ans;
}
int main() {
  int n;
  while (cin >> n) {
    memset(num, 0, sizeof(num));
    fp.clear();
    for (int i = 0; i < n; i++) cin >> num[i], fp[num[i]]++;
    sort(num, num + n);
    int ans = 0;
    int N = unique(num, num + n) - num;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (i == j && fp[num[i]] == 1) continue;
        fp[num[i]]--, fp[num[j]]--;
        ans = max(ans, DFS(num[i], num[j]) + 2);
        fp[num[i]]++, fp[num[j]]++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
