#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, temp1, temp2, balance = 0, score = 1, res = 1, i, cur, pos = 0;
  scanf("%d", &n);
  scanf("%d", &temp1);
  for (i = 1; i < n; i++) {
    scanf("%d", &temp2);
    cur = temp2 - temp1;
    if (cur == balance) {
      res = max(res, score);
      score = i - pos + 1;
    } else
      score++;
    if (abs(cur) > 0) {
      pos = i;
      balance = cur;
    }
    temp1 = temp2;
  }
  res = max(res, score);
  printf("%d", res);
}
