#include <bits/stdc++.h>
using namespace std;
template <typename T, typename T1>
T amax(T &a, T1 b) {
  if (b > a) a = b;
  return a;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, ans = 0, cur = 1;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
  }
  vector<int> vec2 = vec;
  for (int i = 0; i < n; i++) {
    vec2[i] /= 2;
  }
  for (int i = 1; i < n; i++) {
    if (vec2[i] == vec2[i - 1]) {
      cur++;
      amax(ans, cur);
    } else {
      cur = 1;
    }
  }
  vec2 = vec;
  for (int i = 0; i < n; i++) {
    vec2[i] = (vec2[i] + 1) / 2;
  }
  cur = 1;
  for (int i = 1; i < n; i++) {
    if (vec2[i] == vec2[i - 1]) {
      cur++;
      amax(ans, cur);
    } else {
      cur = 1;
    }
  }
  cout << ans;
}
