#include <bits/stdc++.h>
using namespace std;
int a[110];
int main() {
  int t = 0, n = 1, m = 1;
  cin >> t;
  a[0] = 0;
  for (int i = 1; i <= t; i++) {
    cin >> a[i];
  }
  a[t + 1] = 1001;
  for (int i = 1; i <= (t + 1); i++) {
    if (a[i] == (a[i - 1] + 1)) {
      m++;
    } else {
      if (m > n) {
        n = m;
      }
      m = 1;
    }
  }
  if (m > n) {
    n = m;
  }
  if (n > 2) {
    cout << n - 2 << endl;
  } else {
    cout << "0" << endl;
  }
  return 0;
}
