#include <bits/stdc++.h>
using namespace std;
long long n, a[1005], i, dem = 0, kq = 0, t;
void Enter() {
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  Enter();
  for (i = 1; i <= n; i++) {
    t = i;
    while (a[t] + 1 == a[t + 1] && t <= n) {
      dem++;
      t++;
    }
    if (a[t] == 1000) dem++;
    if (a[i] == 1) dem++;
    if (kq < dem) kq = dem - 1;
    dem = 0;
  }
  cout << kq;
}
