#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int M = 1e9 + 7;
int mul(int a, int b) { return (long long int)a * b % M; }
int power(int a, int b) {
  if (b == 0) return 1;
  int temp = power(a, b / 2);
  if (b % 2 == 0)
    return mul(temp, temp);
  else
    return mul(a, mul(temp, temp));
}
int inv(int v) { return power(v, M - 2); }
int arr[1003];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) cin >> arr[i];
  int cont, maxi;
  cont = maxi = 0;
  for (int i = 1; i < t; i++) {
    if ((arr[i] - arr[i - 1]) == 1) {
      cont++;
      if ((i == 1 && arr[i - 1] == 1) || (i == (t - 1) && arr[i] == 1000))
        cont++;
    } else {
      maxi = max(cont - 1, maxi);
      cont = 0;
    }
  }
  maxi = max(maxi, cont - 1);
  cout << maxi << endl;
}
