/// Bismillah Hir Rahmanir Rahim #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define PI acos(-1.0) #define Pi 3.141592653589793 #define ff first #define ss second #define mp make_pair #define pb push_back #define eb emplace_back #define mod 1e7 #define EPS 1e-9 #define INF INT_MAX #define space " " #define all(x) (x).begin(), (x).end() #define clr(ar) memset(ar, 0, sizeof(ar)) #define setdp(ar) memset(ar, -1, sizeof(ar)) #define DFS_BLACK 1 #define DFS_WHITE 0 #define White 0 #define Black 1 /* template T gcd(T a,T b){ if(b == 0) return a; return gcd( b,a % b ); } template T lcm(T a, T b ){ return ( a * b ) / gcd( a,b ); } template string ToString(const T &x){ stringstream s; s << x; return s.str(); } template int ToInteger(const T &x){ stringstream s; s << x; int r; s >> r; return r; } */ const int dr[] = { -1, 1, 0, 0 }; /// 4 side moves. const int dc[] = { 0, 0, -1, 1 }; const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }; /// 8 side moves. const int dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 }; const int kr[] = { 1, 1, -1, -1, 2, 2, -2, -2 }; /// Knight Moves. const int kc[] = { 2, -2, 2, -2, 1, -1, 1, -1 }; typedef long long int ll; typedef map msi; typedef map mss; typedef map mii; typedef map mll; typedef map mci; typedef map mis; typedef pair ii; typedef pair psi; typedef pair pss; typedef vector vi; typedef vector vs; typedef vector vc; typedef vector vb; typedef vector< ii > vii; template void deb(T1 e1) { cout << e1 << endl; } template void deb(T1 e1, T2 e2) { cout << e1 << space << e2 << endl; } template void deb(T1 e1, T2 e2, T3 e3) { cout << e1 << space << e2 << space << e3 << endl; } #define sf scanf #define pf printf #define sf1(a) scanf("%d", &a) #define sf2(a,b) scanf("%d %d",&a, &b) #define sf3(a,b,c) scanf("%d %d %d", &a, &b, &c) #define sf1ll(a) scanf("%I64d", &a) #define sf2ll(a,b) scanf("%I64d %I64d", &a, &b) #define sf3ll(a,b,c) scanf("%I64d %I64d %I64d", &a, &b, &c) #define READ freopen("input.txt", "r", stdin); #define WRITE freopen("output.txt", "w", stdout); /// The End. const int res = 1e3 + 10; int main() { int n, total, a[105], digit = 0, maxi = INT_MIN, temp, sum; mii m; sf1( n ); for( int i = 0; i < n; i++ ) { int x; sf1( x ); m[x]++; } for( auto it: m ) { if( it.ss > maxi ) { maxi = it.ss; } if( digit != 0) { if(abs( it.ff - sum ) <= 1) { int xx = it.ss + temp; if( xx > maxi ) { maxi = xx ; } } } sum = it.first ; temp = it.ss; digit++; } deb( maxi ); return 0; }