#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ansmax = 0, ans = 0;
  cin >> n;
  int a[n + 2];
  for (int i = 1; i <= n; i++) cin >> a[i];
  a[0] = 0;
  a[n + 1] = 1001;
  for (int i = 1; i <= n; i++) {
    if (a[i] == a[i - 1] + 1 && a[i + 1] - 1 == a[i]) {
      ans++;
      ansmax = max(ans, ansmax);
    } else
      ans = 0;
  }
  cout << ansmax;
}
