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