#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> s;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s[a[i]]++;
  }
  int ans = 2;
  map<int, set<int> > tried;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (tried[a[i]].count(a[j]) == 0) {
        map<int, int> cnt;
        cnt[a[i]]++;
        cnt[a[j]]++;
        if (cnt[a[i]] > s[a[i]]) continue;
        int c = 2;
        tried[a[i]].insert(a[j]);
        int x = a[i], y = a[j];
        while (s.count(x + y) != 0 && s[x + y] > cnt[x + y]) {
          c++;
          int t = x + y;
          x = y;
          y = t;
          cnt[y]++;
          tried[x].insert(y);
        }
        x = a[i];
        y = a[j];
        while (s.count(y - x) != 0 && s[y - x] > cnt[y - x]) {
          c++;
          int t = y - x;
          y = x;
          x = t;
          cnt[x]++;
          tried[x].insert(y);
        }
        if (c > ans) ans = c;
      }
    }
  }
  cout << ans;
  return 0;
}
