#include using namespace std; int main(){ int N; cin >> N; vector A(N); for (int i = 0; i < N; i++){ cin >> A[i]; } map mp; for (int i = 0; i < N; i++){ mp[A[i]]++; } int ans = 0; for (int i = 0; i < N; i++){ ans = max(ans, mp[A[i] - 1] + mp[A[i]]); ans = max(ans, mp[A[i]] + mp[A[i] + 1]); } cout << ans << endl; }