#include #include #include #include #include using namespace std; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int n; cin >> n; int a[n],c = 0; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); int mx = 0; for (int i = 0; i < n - 1; i++) { int x = a[i], y = a[i + 1], c = 0; if (y - x > 1) continue; for (int j = 0; j < n; j++) { if (a[j] == x or a[j] == y) { c++; } } mx = max(c, mx); } for (int j = 0; j < n; j++) { c = 0; for (int i = 0; i < n; i++) { c += (a[i] == a[j]); } mx = max(c, mx); } cout << mx << endl; return 0; }