#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int a[100005];
map<int, int> mp;
map<pair<int, int>, int> mm;
int s;
int dfs(int a, int b) {
  if (a == 0 && b == 0) return mp[0];
  if (mp[a + b] == 0) return 0;
  if (mp[a + b] > 0) {
    mp[a + b]--;
    s = dfs(b, a + b) + 1;
    mp[a + b]++;
    return s;
  }
}
int main() {
  int i, j, n;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    mp[a[i]]++;
  }
  int ans = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (i != j) {
        mp[a[j]]--;
        mp[a[i]]--;
        s = 0;
        ans = max(ans, dfs(a[i], a[j]) + 2);
        mp[a[i]]++;
        mp[a[j]]++;
      }
    }
  }
  printf("%d\n", ans);
}
