#include <bits/stdc++.h>
using namespace std;
long long f(long long n) {
  if (n > 50) return n - 10;
  return f(f(n));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int a[n + 2];
  a[0] = 0;
  for (int i = 1; i <= n; i++) cin >> a[i];
  a[n + 1] = 1001;
  int ans = 0;
  int cnt = 1;
  int prev = 0;
  for (int i = 1; i <= n + 1; i++) {
    if (a[i] != (prev + 1)) {
      ans = max(ans, cnt - 2);
      cnt = 1;
    } else
      cnt++;
    prev = a[i];
  }
  ans = max(ans, cnt - 2);
  if (ans <= 0) ans = 0;
  cout << ans;
  return 0;
}
