#include using namespace std; #define sz(v) int(v.size()) int main(){ int n; cin >> n; map mapper; for(int i = 0 ; i < n ; i++){ int x; cin >> x; mapper[x]++; } map::iterator it; int ans = 0; it = mapper.begin() ; pairprev; prev.first = it->first; prev.second = it->second; it++; ans = max(ans , prev.second); for(; it!=mapper.end();it++){ ans = max(ans, it->second); if(abs(prev.first - it->first)<=1) ans = max(ans,it->second + prev.second); prev = {it->first,it->second}; } cout << ans << endl; }