#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> v;
  int n;
  cin >> n;
  v.push_back(0);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  v.push_back(1001);
  n = n + 2;
  int cnt = 0, maxcnt = 0;
  for (int i = n; i > 0; i--) {
    if (v[i] - v[i - 1] == 1)
      cnt++;
    else {
      if (maxcnt < cnt) {
        maxcnt = cnt;
      }
      cnt = 0;
    }
  }
  cout << max(max(maxcnt, cnt) - 1, 0) << endl;
  return 0;
}
