fa0810ad370e65cc7f0ee961b6259eec9b565efcc2d486e36cde5fdccbc585ea
// https://szkopul.edu.pl/problemset/problem/KiEvCpZBaUNRCp6oTZx2oAQ4/site/?key=statement
// OIG I (2 etap)
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>
int main() {
std::ios_base::sync_with_stdio(0);
std::cin.tie(0);
std::cout.tie(0);
int n;
std::cin >> n;
std::vector<int> v(n);
for (int i = 0; i < n; i++) {
int a;
std::cin >> a;
v[i] = a;
}
std::sort(v.begin(), v.end());
int ans = 0;
int o = 0, g = 1;
while (o < v.size() && g < v.size()) {
if (g == v.size() - 1) {
ans = std::max(ans, g - o + 1);
break;
}
if (g - o + 1 < 2) {
g++;
} else if (v[o] + v[o + 1] > v[g + 1]) {
g++;
} else {
ans = std::max(ans, g - o + 1);
o++;
}
}
if (ans < 3) {
ans = 0;
}
std::cout << ans << '\n';
return 0;
}