#include <iostream> #include <queue> #include <map> #include <set> #include <cmath> #include <cstring> #include <algorithm> #include <iomanip> #include <stack> #include <numeric> #include <ctime> #include <string> #include <bitset> #include <unordered_map> #include <unordered_set> using namespace std; using ll = long long; const ll N = 1e5 + 5, mod = 1e9 + 7, inf = 2e18; const double esp = 1e-9; int n; int a[N]; void solve() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } int cont = 1, ans = 0; for (int i = 2; i <= n; i++) { if (i == n && abs(a[i] - a[i - 1] <= 1))cont++; if (abs(a[i] - a[i - 1]) > 1 || i == n) { ans = max(ans, cont); cont = 1; } else { cont++; } } cout << ans; } int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); int t = 1; // cin >> t; while (t--) { solve(); } return 0; }