#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3 + 3;
int n;
int a[MAXN];
unordered_map<int, int> occ;
void init() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    ++occ[a[i]];
  }
}
int getMaxLength(int f0, int f1) {
  unordered_map<int, int> used;
  ++used[f0], ++used[f1];
  int res = 2;
  while (true) {
    int f2 = f0 + f1;
    if (used[f2] + 1 > occ[f2]) break;
    ++used[f2];
    ++res;
    f0 = f1, f1 = f2;
  }
  return res;
}
void solve() {
  set<pair<int, int> > vis;
  int best = occ[0] >= 2 ? occ[0] : 0;
  ;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j)
      if (i != j) {
        if (a[i] == 0 && a[j] == 0) continue;
        if (vis.count(pair<int, int>(a[i], a[j]))) continue;
        vis.insert(pair<int, int>(a[i], a[j]));
        best = max<int>(best, getMaxLength(a[i], a[j]));
      }
  }
  printf("%d\n", best);
}
int main() {
  init();
  solve();
  return 0;
}
