#include <bits/stdc++.h>
using namespace std;
const double eps = 1E-9;
const double Exp = 2.718281828459045;
const double pi = 3.14159;
const double E = 2.7182818284590452354;
const int Max_Bit = 63;
const int INF = 2000000000;
const long long LINF = 1000000000000000007ll;
const int MOD = 1000000007;
const int NMAX = 100005;
const int MMAX = 100000;
const int base = 1000 * 1000 * 1000;
int ok(int a, int b) {
  if (a < b) return 1;
  if (a > b) return -1;
  return 0;
}
int main() {
  int n, a[NMAX], ans = 0, p[NMAX], kol = 0, last = 1;
  cin >> n;
  cin >> a[1] >> a[2];
  if (a[1] < a[2]) {
    p[1] = 1;
  }
  if (a[1] > a[2]) p[1] = -1;
  if (a[1] == a[2]) p[1] = 0;
  kol = 1;
  for (int i = 3; i <= n; i++) {
    cin >> a[i];
    p[i - 1] = ok(a[i - 1], a[i]);
    if ((p[i - 1] == 1 && p[last] == 1) || (p[i - 1] == -1 && p[last] == -1)) {
      ans = max(ans, kol + 1);
      kol = i - 1 - last;
      last = i - 1;
    } else {
      if (p[i - 1] == 1 || p[i - 1] == -1) last = i - 1;
      kol++;
    }
  }
  ans = max(ans, kol + 1);
  cout << ans << endl;
  return 0;
}
