#include <bits/stdc++.h>
int main() {
  int n;
  std::cin >> n;
  int s, t;
  std::cin >> s >> t;
  int lp = t - s;
  int lc;
  int max = 2;
  int cur = 2;
  int p = 1;
  s = t;
  for (int i = 2; i < n; ++i) {
    std::cin >> t;
    if ((t - s) && (t - s == lp)) {
      cur = i - p + 1;
      p = i;
    } else {
      ++cur;
      if (t - s) p = i;
      if (cur > max) max = cur;
    }
    if (t - s) lp = t - s;
    s = t;
  }
  std::cout << max << std::endl;
}
