#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long n;
  cin >> n;
  long long a[n + 5];
  long long c = 0, f = 0, in1, in2, mx = 0;
  a[0] = -1000;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  a[n + 1] = 10000;
  for (long long i = 0; i <= (n + 1); i++) {
    if (a[i + 1] - a[i] == 1 && f == 0) {
      in1 = a[i];
      f = 1;
    } else if ((a[i + 1] - a[i]) > 1 && f == 1) {
      in2 = a[i];
      f = 0;
      c = (in2 - in1 - 1);
      if (in1 == 1 || in2 == 1000) c++;
      mx = max(mx, c);
    }
  }
  cout << mx << endl;
  return 0;
}
