#include <bits/stdc++.h>
using namespace std;
int a[200];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int res = 0, ans = 0;
  a[0] = -10;
  for (int i = 1; i <= n; i++) {
    if (a[i] == a[i - 1] + 1)
      res++;
    else
      res = 0;
    ans = max(res, ans);
  }
  ans = max(ans - 1, 0);
  int f1 = 0;
  for (int i = 1; i <= n + 1; i++) {
    if (a[i] == i) {
      f1++;
    }
  }
  int f2 = 0;
  for (int i = n; i >= 0; i--) {
    if (a[i] == (1000 - n + i)) {
      f2++;
    }
  }
  if (f1 >= n || f2 >= n) {
    f1 = n;
    f2 = n;
  }
  ans = max(ans, max(f1, f2) - 1);
  printf("%d\n", ans);
}
