#include <bits/stdc++.h>
using namespace std;
int main() {
  long n;
  int l = 1, ans = 1, x, y, s = 0;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  x = a[0] - a[1];
  for (int i = 0; i < n - 1; i++) {
    y = a[i + 1] - a[i];
    if (x + y == 0 or y == 0) {
      l = l + 1;
    } else {
      l = 2 + s;
      s = 0;
    }
    if (y != 0) {
      x = y;
      s = 0;
    } else {
      s = s + 1;
    }
    ans = max(ans, l);
  }
  cout << ans;
  return 0;
}
