#include <bits/stdc++.h>
#pragma GCC optimize("-Ofast", "-funroll-all-loops")
using namespace std;
const int N = 1e3 + 10;
int n, a[N], res;
map<int, int> mp;
signed main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i], mp[a[i]]++;
  res = max(res, mp[0]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (i != j) {
        if (!a[i] && !a[j]) continue;
        int mx = 2, now = a[i] + a[j], pre = a[j];
        map<int, int> tmp;
        tmp[a[i]] = 1, tmp[a[j]] = 1;
        while (tmp[now] < mp[now]) {
          tmp[now]++;
          int f = now;
          now = now + pre;
          pre = f;
          mx++;
        }
        res = max(res, mx);
      }
  cout << res;
  return 0;
}
