#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1005;
long long n;
long long a[maxn], mx = 0;
unordered_map<long long, long long> mp;
void go(long long a, long long b) {
  if (!a && !b) {
    mx = max(mx, mp[0]);
    return;
  }
  vector<long long> v;
  long long f1 = 0, f2 = 1, f3 = 1;
  long long res = 2;
  mp[a]--, mp[b]--;
  for (long long i = 1; i <= 100; i++) {
    long long t = a * f2 + b * f3;
    if (mp.count(t) && mp[t])
      res++, mp[t]--, v.push_back(t);
    else
      break;
    f1 = f2, f2 = f3, f3 = f1 + f2;
  }
  for (long long x : v) mp[x]++;
  mp[a]++, mp[b]++;
  mx = max(res, mx);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    mp[a[i]]++;
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) {
      if (i - j) go(a[i], a[j]);
    }
  }
  cout << mx;
}
