#include <bits/stdc++.h>
using namespace std;
int n, ans, len;
int a[2333];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  a[0] = 0;
  a[n + 1] = 1001;
  for (int i = 1; i <= n + 1; i++) {
    if (a[i] == a[i - 1] + 1)
      len++;
    else {
      ans = max(ans, len - 1);
      len = 0;
    }
  }
  ans = max(ans, len - 1);
  printf("%d", ans);
  return 0;
}
