#include <bits/stdc++.h>
const int maxn = 1e3 + 10, mxx = 1e9;
using namespace std;
long long n, k, a[maxn], ms;
unordered_map<long long, long long> mp;
unordered_map<long long, long long> cp;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]]++;
    if (mp[a[i]] > 2) {
      a[i] = 0;
      i--;
      n--;
    }
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      long long an0, an1, an2, sz = 2;
      an0 = a[i];
      an1 = a[j];
      an2 = a[i] + a[j];
      cp = unordered_map<long long, long long>();
      cp[an0]++;
      cp[an1]++;
      while (cp[an2] < mp[an2]) {
        cp[an2]++;
        sz++;
        an0 = an1;
        an1 = an2;
        an2 = an0 + an1;
        if (an2 > mxx) break;
      }
      ms = max(ms, sz);
    }
  cout << ms;
}
