#include <bits/stdc++.h>
using namespace std;
bool cmp(int a, int b) {
  if (a > b)
    return (true);
  else
    return (false);
}
int main() {
  int n, a[2000], i, j, c = 0, k = 0, b[2000];
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  if (a[0] == 1 && a[1] == 2) c++;
  for (i = 1; i < n - 1; i++) {
    if (a[i] == (a[i + 1] - 1) && a[i] == (a[i - 1] + 1)) {
      c++;
    } else {
      b[k] = c;
      k++;
      c = 0;
    }
  }
  if (a[n - 1] == 1000 && a[n - 2] == 999) {
    c++;
    b[k] = c;
    k++;
    c = 0;
  }
  b[k] = c;
  k++;
  c = 0;
  sort(b, b + k, cmp);
  printf("%d", b[0]);
}
