#include <bits/stdc++.h>
using namespace std;
const int maxn = 150000 + 1;
const int maxm = 10000;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int a[maxn];
int vis[maxn];
int n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  a[n + 1] = 1001;
  n++;
  int ans = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (j - i + 1 == a[j] - a[i] + 1)
        for (int k = i + 1; k <= j - 1; k++) ans = max(ans, j - i - 1);
    }
  }
  printf("%d\n", ans);
  return 0;
}
