#include <bits/stdc++.h>
using namespace std;
const int maxn = 107;
int main() {
  int ans = 0, cnt = 0, n = 0, A[maxn];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &A[i]);
  if (A[0] == 1) cnt++;
  for (int i = 1; i < n; i++) {
    ans = max(cnt - 1, ans);
    if (A[i] - A[i - 1] == 1)
      cnt++;
    else
      cnt = 0;
  }
  ans = max(A[n - 1] == 1000 ? cnt : cnt - 1, ans);
  cout << ans << endl;
  return 0;
}
