#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 100;
const int MINVAL = 1;
const int MAXVAL = 1000;
int n;
int a[MAXN];
int solve() {
  int ret = 0, cur = 0;
  for (int i = (0); i < (n); ++i) {
    if (i - 1 >= 0 && a[i - 1] < a[i] - 1 || i == 0 && a[i] - 1 >= MINVAL) {
      cur = 0;
      continue;
    }
    if (i + 1 < n && a[i + 1] > a[i] + 1 || i + 1 == n && a[i] + 1 <= MAXVAL) {
      cur = 0;
      continue;
    }
    ++cur;
    ret = max(ret, cur);
  }
  return ret;
}
void run() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) scanf("%d", &a[i]);
  printf("%d\n", solve());
}
int main() {
  run();
  return 0;
}
