#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1050;
pair<int, int> a[MAX_N];
int cnt[MAX_N];
int sub[MAX_N];
map<int, int> ids;
int inds[MAX_N];
int id = 0;
int countplz(int f0, int f1) {
  memset((sub), 0, sizeof(sub));
  ++sub[a[f0].second];
  ++sub[a[f1].second];
  int ans = 2;
  while (true) {
    int fnval = a[f0].first + a[f1].first;
    auto it = ids.find(fnval);
    if (it == ids.end()) {
      return ans;
    }
    int fnid = it->second;
    int fn = inds[fnid];
    int rest = cnt[fnid] - sub[fnid];
    if (rest <= 0) {
      return ans;
    }
    ++ans;
    sub[fnid]++;
    f0 = f1;
    f1 = fn;
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    if (ids.count(x) == 0) {
      ids[x] = id;
      inds[id] = i;
      ++id;
    }
    a[i] = make_pair(x, ids[x]);
    cnt[ids[x]]++;
  }
  int maxs = 2;
  if (ids.count(0) > 0) {
    maxs = max(maxs, cnt[ids[0]]);
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i == j || (a[i].first == a[j].first && a[i].first == 0)) {
        continue;
      }
      maxs = max(maxs, countplz(i, j));
    }
  }
  cout << maxs << endl;
  return 0;
}
