#include #define pb push_back #define mp make_pair #define ll long long #define ull unsigned long long using namespace std; int main() { bool testing = false; std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); if(testing) { freopen("test.txt","rt",stdin); //freopen("out.txt","wt",stdout); } int n; cin >> n; int arr[n]; for(int i = 0; i < n; ++i) { cin >> arr[i]; } sort(arr, arr+n); long long max = -1; for(int i = 0; i < n; ++i) { int count = 0; int temp = i; while(abs(arr[i]-arr[temp+1]) <= 1) { ++count; ++temp; } if(count > max) { max = count; } } if(max != 0) { max++;} cout << max << endl; }