#include <bits/stdc++.h>
using namespace std;
int shu[1008];
int he[1008][1008];
int len[1008][1008];
int used[1008];
map<int, int> mapa;
int n;
int hehe;
int getdp(int i, int j) {
  if (used[j] == 0) return 1;
  if (he[i][j] == -1) return 2;
  used[j]--;
  int t = getdp(j, he[i][j]) + 1;
  used[j]++;
  return t;
}
int main() {
  int t;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &t);
    if (mapa.find(t) == mapa.end()) {
      mapa.insert({t, i});
      shu[i] = t;
      used[i] = 1;
    } else {
      i--;
      n--;
      used[mapa[t]]++;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      hehe = shu[i] + shu[j];
      if (mapa.find(hehe) != mapa.end()) {
        he[i][j] = mapa[hehe];
        he[j][i] = mapa[hehe];
      } else {
        he[i][j] = -1;
        he[j][i] = -1;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (j == i && used[i] == 1) continue;
      used[i]--;
      len[i][j] = getdp(i, j);
      used[i]++;
    }
  }
  int maxl = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (len[i][j] > maxl) {
        maxl = len[i][j];
      }
    }
  }
  cout << maxl << endl;
  return 0;
}
