#include <bits/stdc++.h>
using namespace std;
int a[105];
int n;
bool Valid(int x, int y) {
  for (int i = x + 1; i <= y; i++) {
    if (a[i] != a[i - 1] + 1) return false;
  }
  return true;
}
int main() {
  scanf("%d", &n);
  if (n == 1) {
    printf("0");
    return 0;
  } else if (n == 1000) {
    printf("1000");
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  int ans = 0;
  a[0] = 0;
  a[n + 1] = 1001;
  for (int l = 0; l <= n + 1; l++) {
    for (int len = 1; l + len - 1 <= n + 1; len++) {
      int r = l + len - 1;
      if (Valid(l, r)) {
        if (r - l - 1 > ans) ans = r - l - 1;
      } else
        break;
    }
  }
  printf("%d", ans);
  return 0;
}
