#include <bits/stdc++.h>
using namespace std;
const int MAXN = 105;
int n, a[MAXN], ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int num = 1;
  for (int i = 2; i <= n; i++) {
    if (a[i] == a[i - 1] + 1)
      num++;
    else {
      ans = max(ans, num - 2);
      if ((i - 1) == num && a[1] == 1) ans = max(ans, num - 1);
      num = 1;
    }
  }
  ans = max(ans, num - 2);
  if (a[n] == 1000) ans = max(ans, num - 1);
  if (num == n && a[1] == 1) ans = max(ans, num - 1);
  printf("%d\n", ans);
}
