#include <bits/stdc++.h>
using namespace std;
int n, a[110];
int main() {
  while (scanf("%d", &n) != EOF) {
    for (int i = 1; i <= n; ++i) scanf("%d", a + i);
    a[0] = 0;
    a[n + 1] = 1001;
    int res = 0, tmp = 1;
    for (int i = 1; i <= n + 1; ++i) {
      if (a[i] == a[i - 1] + 1)
        ++tmp;
      else {
        res = max(res, tmp - 2);
        tmp = 1;
      }
    }
    res = max(res, tmp - 2);
    printf("%d\n", res);
  }
  return 0;
}
