#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, l = 0, p = 0, d = 0, ans = 0;
  cin >> n;
  int A[n];
  for (int i = 0; i < n; i++) cin >> A[i];
  for (int i = 1; i < n; i++) {
    if (A[i] != A[i - 1]) {
      if (A[i] - A[i - 1] == d) l = p;
      d = A[i] - A[i - 1];
      p = i;
    }
    ans = max(ans, i - l + 1);
  }
  cout << ans;
  return 0;
}
