#include <bits/stdc++.h>
int dfs(int a, int b, std::map<int, int>& cnt) {
  if (cnt[a + b] != 0) {
    cnt[a + b]--;
    int ret = 1 + dfs(b, a + b, cnt);
    cnt[a + b]++;
    return ret;
  }
  return 0;
}
int main() {
  int numbers;
  std::scanf("%d", &numbers);
  std::vector<int> values;
  std::map<int, int> cnt;
  for (int i = 0; i < numbers; i++) {
    int next;
    std::scanf("%d", &next);
    values.push_back(next);
    cnt[next]++;
  }
  constexpr int MAXN = 1000;
  int answer = 0;
  std::set<std::pair<int, int>> done;
  for (int i = 0; i < numbers; i++) {
    for (int j = 0; j < numbers; j++) {
      if (i == j) continue;
      if (done.find({values[i], values[j]}) != done.end()) continue;
      cnt[values[i]]--;
      cnt[values[j]]--;
      answer = std::max(answer, 2 + dfs(values[i], values[j], cnt));
      done.insert({values[i], values[j]});
      cnt[values[i]]++;
      cnt[values[j]]++;
    }
  }
  std::cout << answer << std::endl;
  return EXIT_SUCCESS;
}
