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