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