#include <bits/stdc++.h>
using namespace std;
const int NMAX = 1e6 + 7;
int n, a[NMAX];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  a[0] = 0;
  a[n + 1] = 1001;
  int res = 0;
  for (int i = 0; i <= n + 1; ++i)
    for (int j = i + 1; j <= n + 1; ++j)
      if ((a[j] - a[i]) == (j - i)) res = max(res, j - i - 1);
  cout << res;
}
