#include <bits/stdc++.h>
using namespace std;
map<long long int, int> M;
set<pair<int, int> > S;
map<long long int, int> I;
int main() {
  int N;
  cin >> N;
  vector<long long int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (M.find(A[i]) != M.end()) {
      M[A[i]] += 1;
    } else {
      M[A[i]] = 1;
    }
  }
  sort(A.begin(), A.end());
  int cnt = 0;
  I[A[0]] = 0;
  vector<int> tmp;
  tmp.push_back(0);
  for (int i = 1; i < N; i++) {
    if (A[i] > A[i - 1]) {
      I[A[i]] = i;
      tmp.push_back(i);
    }
  }
  for (int i = 0; i < tmp.size(); i++) {
    for (int j = 0; j < tmp.size(); j++) {
      if (tmp[i] != tmp[j]) {
        S.insert(make_pair(tmp[i], tmp[j]));
      } else {
        if (M[A[tmp[i]]] > 1) {
          S.insert(make_pair(tmp[i], tmp[j]));
        }
      }
    }
  }
  deque<long long int> D;
  deque<int> index;
  int ans = 2;
  while (!S.empty()) {
    while (D.size() > 2) {
      long long int f = D[0];
      if (M.find(f) != M.end()) {
        M[f] += 1;
      } else {
        M[f] = 1;
      }
      D.pop_front();
      index.pop_front();
      if (S.find(make_pair(index[0], index[1])) != S.end())
        S.erase(make_pair(index[0], index[1]));
      else {
        break;
      }
      ans = max(ans, 2);
      while (M.find(D[D.size() - 2] + D[D.size() - 1]) != M.end() and
             M[D[D.size() - 2] + D[D.size() - 1]] > 0) {
        M[D[D.size() - 2] + D[D.size() - 1]] -= 1;
        index.push_back(I[D[D.size() - 2] + D[D.size() - 1]]);
        D.push_back(D[D.size() - 2] + D[D.size() - 1]);
        ans = max(ans, (int)D.size());
      }
    }
    if (!S.empty()) {
      int i = S.begin()->first;
      int j = S.begin()->second;
      S.erase(S.begin());
      for (int k = 0; k < D.size(); k++) {
        M[D[k]] += 1;
      }
      D.clear();
      index.clear();
      D.push_back(A[i]);
      M[A[i]] -= 1;
      M[A[j]] -= 1;
      D.push_back(A[j]);
      index.push_back(i);
      index.push_back(j);
      ans = max(ans, 2);
      while (M.find(D[D.size() - 2] + D[D.size() - 1]) != M.end() and
             M[D[D.size() - 2] + D[D.size() - 1]] > 0) {
        M[D[D.size() - 2] + D[D.size() - 1]] -= 1;
        index.push_back(I[D[D.size() - 2] + D[D.size() - 1]]);
        D.push_back(D[D.size() - 2] + D[D.size() - 1]);
        ans = max(ans, (int)D.size());
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
