#include <bits/stdc++.h>
using namespace std;
int aray[100002];
int main() {
  int i, j, k, a, b, x, n, y, p, q, len, mx = 0, s = 1;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &aray[i]);
  }
  p = 0;
  q = 0;
  s = 0;
  for (i = 1; i < n; i++) {
    a = aray[i] - aray[i - 1];
    if (a) {
      if (p == a) {
        s = q;
      }
      q = i;
      p = a;
    }
    len = i - s + 1;
    if (len > mx) mx = len;
  }
  cout << mx;
  return 0;
}
