/* Solved By : Kazi Mahbubur Rahman (cryptic.coder) Time : Rank : Complexity: */ #define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define FOR(i, L, U) for(int i=(int)L; i<=(int)U; i++) #define FORD(i, U, L) for(int i=(int)U; i>=(int)L; i--) #define READ(x) freopen(x, "r", stdin) #define WRITE(x) freopen(x, "w", stdout) #define ff first #define ss second #define PQ priority_queue #define PB push_back #define SZ size() #define EPS 1e-9 #define SQR(x) ((x)*(x)) #define INF 2000000000 #define TO_DEG 57.29577951 #define PI 2*acos(0.0) #define ALL_BITS ((1 << 31) - 1) #define NEG_BITS(mask) (mask ^= ALL_BITS) #define TEST_BIT(mask, i) (mask & (1 << i)) #define ON_BIT(mask, i) (mask |= (1 << i)) #define OFF_BIT(mask, i) (mask &= NEG_BITS(1 << i)) #define IS_POWER_TWO(x) (x && !(x & (x-1))) #define OFF_RIGHTMOST_SET_BIT(x) (x & (x-1)) typedef long long LL; typedef unsigned long long ULL; typedef pair PII; typedef pair PDD; typedef vector VB; typedef vector VI; typedef vector VD; typedef vector VC; typedef vector VS; typedef map MII; typedef map MCI; typedef map MSI; typedef vector > VVB; typedef vector > VVI; typedef vector > VVD; typedef vector > VVPII; int GCD(int a, int b) { while (b)b ^= a ^= b ^= a %= b; return a; } // UP, RIGHT, DOWN, LEFT, UPPER-RIGHT, LOWER-RIGHT, LOWER-LEFT, UPPER-LEFT int dx[8] = { -1, 0, 1, 0, -1, 1, 1, -1 }; int dy[8] = { 0, 1, 0,-1, 1, 1, -1, -1 }; // Represents all moves of a knight in a chessboard int dxKnightMove[8] = { -1, -2, -2, -1, 1, 2, 2, 1 }; int dyKnightMove[8] = { 2, 1, -1, -2, -2, -1, 1, 2 }; inline int src() { int ret; scanf("%d", &ret); return ret; } #define WHITE 0 #define GRAY 1 #define BLACK 2 #define MAX 107 int N; int arr[MAX]; int f[MAX]; int main() { //READ("input.txt"); //WRITE("output.txt"); int i, j, k; int TC, tc; double cl = clock(); cin >> N; FOR(i, 0, N - 1) { cin >> arr[i]; f[arr[i]]++; } int ans = 0; for (int i = 0; i < 99; i++) { if (f[i] >= 2) ans = max(ans, f[i]); if (f[i + 1] >= 2) ans = max(ans, f[i+1]); if (f[i] && f[i + 1]) { ans = max(ans, f[i] + f[i + 1]); } } cout << ans << endl; cl = clock() - cl; fprintf(stderr, "Total Execution Time = %lf seconds\n", cl / CLOCKS_PER_SEC); return 0; }