#include <bits/stdc++.h>
int main() {
  int n, a[1005], ans = 0, m, l = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  a[0] = 0;
  a[n + 1] = 1001;
  for (int i = 0; i <= n; i++) {
    if (a[i + 1] == a[i] + 1) {
      l++;
    } else {
      if (l >= 2 && ans < l - 1) {
        ans = l - 1;
      }
      l = 0;
    }
  }
  if (l >= 2 && ans < l - 1) {
    ans = l - 1;
  }
  printf("%d\n", ans);
  return 0;
}
