#include "bits/stdc++.h"
using namespace std;
#define int long long
#define pb push_back
#define endl "\n"
#define x first
#define y second
#define PII pair<int,int>
#define PIII pair<int,PII>
const int MOD = 1e9 + 7;
const int N = 3e5;
void slu() {
int n;
cin >> n;
vector<int> a(n);
int res = 0;
for (int i = 0; i < n; i++)cin >> a[i];
int cnt = 1;
for (int i = 1; i < n; i++) {
if (abs(a[i] - a[i - 1]) <= 1)cnt++;
else {
res = max(res, cnt);
cnt = 1;
}
}
cout << max(res, cnt) << endl;
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int T;
// cin >> T;
T = 1;
while (T--)slu();
}