#include <bits/stdc++.h>
using namespace std;
const int MAX = 1010;
int n;
int a[MAX];
map<long long, int> cnt;
map<long long, int> tmp;
int solve(int i, int j) {
  if (!a[i] && !a[j]) return cnt[0];
  tmp.clear();
  int sz = 2;
  long long f0 = a[i];
  long long f1 = a[j];
  if (a[i] == a[j])
    tmp[a[i]] = 2;
  else {
    tmp[a[i]] = 1;
    tmp[a[j]] = 1;
  }
  while (true) {
    if (!cnt.count(f0 + f1)) break;
    int next_cnt = cnt[f0 + f1];
    if (!next_cnt) break;
    if (!tmp.count(f0 + f1)) tmp[f0 + f1] = 0;
    int& tmpcnt = tmp[f0 + f1];
    if (tmpcnt >= next_cnt) break;
    tmpcnt++;
    long long next = f0 + f1;
    f0 = f1;
    f1 = next;
    sz++;
  }
  return sz;
}
set<pair<int, int> > tried;
int main() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) scanf("%d", &a[i]);
  for (int i = (0); i < (n); ++i) {
    if (!cnt.count(a[i])) cnt[a[i]] = 0;
    cnt[a[i]]++;
  }
  if (n == 1) {
    puts("1");
    printf("%d\n", a[0]);
  }
  int res = 2;
  if (n > 2) {
    for (int i = (0); i < (n); ++i) {
      for (int j = (i + 1); j < (n); ++j) {
        if (tried.count(make_pair(a[i], a[j]))) continue;
        res = max(res, solve(i, j));
        tried.insert(make_pair(a[i], a[j]));
      }
    }
    for (int i = n - 1; i >= 0; --i)
      for (int j = (0); j < (i); ++j) {
        if (tried.count(make_pair(a[i], a[j]))) continue;
        res = max(res, solve(i, j));
        tried.insert(make_pair(a[i], a[j]));
      }
  }
  printf("%d\n", res);
  return 0;
}
