#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  int d[n];
  memset(d, 0, sizeof(d));
  int p = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    d[i] = a[i] - p;
    p = a[i];
  }
  int c = 0;
  int x = n - 1;
  if (a[n - 1] == 1000) {
    int t = 1000;
    while (a[x] == t) {
      x--;
      t--;
      c++;
    }
    c--;
  }
  int y = c;
  c = 0;
  int maxi = 0;
  for (int i = 0; i < x; i++) {
    while (d[i] == 1 && d[i + 1] == 1) {
      c++;
      i++;
    }
    maxi = max(c, maxi);
    c = 0;
  }
  cout << max(y, maxi);
}
