#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A;
  A.push_back(0);
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    A.push_back(x);
  }
  A.push_back(1001);
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    for (int j = i; j <= N; j++) {
      if (j - i + 1 == A[j + 1] - A[i - 1] - 1) {
        ans = max(ans, j - i + 1);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
