#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 9;
int a[2000];
int main() {
  int n, cnt = 1, mx = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 1; i < n; i++) {
    if (a[i] - a[i - 1] == 1) {
      cnt++;
      if (a[i - 1] == 1 || a[i] == 1000) cnt++;
    } else {
      mx = max(mx, cnt - 2);
      cnt = 1;
    }
  }
  mx = max(cnt - 2, mx);
  printf("%d\n", mx);
}
