#include #include #include #include #include #include using namespace std; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int n; cin >> n; map m; for(int i = 0;i < n;++i){ int t; cin >> t; ++m[t]; } int _max = 0; for(auto &p : m){ int a = p.second; if(m.find(p.first+1) != m.end()) a+=m[p.first+1]; _max = max(a,_max); } cout << _max << endl; return 0; }