#include <bits/stdc++.h>
namespace xxx {
using namespace std;
const double EPS = 1e-8;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
inline long long rd() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
}  // namespace xxx
using namespace xxx;
const int N = 1e5 + 20;
int n;
int a[N];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  a[n + 1] = 1001;
  a[0] = 0;
  int ans = 0, t = 0;
  for (int i = 1; i <= n + 1; i++) {
    if (a[i] == a[i - 1] + 1) {
      t++;
    } else {
      ans = max(ans, t - 1);
      t = 0;
    }
  }
  ans = max(ans, t - 1);
  cout << ans << endl;
  exit(0);
}
