#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include int *a, n; int match_max = 0; int find_largest_count(int val, int count, int sel, int match) { if (sel == n) { if (match_max 0) { if (a[count] - val <= 1 && val - a[count] <= 1) { find_largest_count(a[count], count + 1, sel + 1, match + 1); } } } } return 0; } int main() { scanf("%d", &n); a = (int *)malloc(sizeof(int) * n); for (int a_i = 0; a_i < n; a_i++) { scanf("%d", &a[a_i]); } int i, j; for (i = 0; i a[j]) { int temp = a[i]; a[i] = a[j]; a[j] = temp; } } } int cnt; for (i = 0; i < n - 1; i++) { cnt = 1; for (j = i + 1; j < n; j++) { if (a[j] - a[i] <= 1) cnt++; else break; } if (cnt > match_max) match_max = cnt; } //find_largest_count(0, 0, 0,1); printf("%d\n", match_max); return 0; }