#include <bits/stdc++.h>
using namespace std;
int findLongest(vector<int> v) {
  int len = 0, maxLen = 0, el = v[0];
  for (int e : v) {
    if (e == el) {
      len++;
    } else {
      maxLen = max(maxLen, len);
      len = 1;
      el = e;
    }
  }
  return max(maxLen, len);
}
int main() {
  int n;
  cin >> n;
  vector<int> odd, even;
  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;
    odd.push_back(t + ((t + 1) % 2));
    even.push_back(t + t % 2);
  }
  cout << max(findLongest(odd), findLongest(even)) << endl;
  return 0;
}
