#include <bits/stdc++.h>
using namespace std;
inline long long Getint() {
  char only = getchar();
  long long my = 1, railgun = 0;
  while (only < '0' || only > '9') {
    if (only == '-') my *= -1;
    only = getchar();
  }
  while (only >= '0' && only <= '9') {
    (railgun *= 10) += (only ^ 48);
    only = getchar();
  }
  return my * railgun;
}
int n, Max, A[105];
int main() {
  n = Getint();
  for (int i = 1; i <= n; i++) A[i] = Getint();
  A[0] = 0;
  A[n + 1] = 1001;
  for (int i = 1, j = 1; i <= n; i++, j = max(j, i)) {
    if (A[i] != A[i - 1] + 1) continue;
    while (j <= n && A[j] + 1 == A[j + 1]) j++;
    Max = max(Max, j - i);
  }
  cout << Max << '\n';
  return 0;
}
