#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma comment(linker, "/STACK:102400000,102400000")
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int EXP = 1e-8;
const int N = 1e5 + 5;
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
const int MAXM = 2e6 + 5;
using namespace std;
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
int a[1005];
int dp[105];
int main() {
  int n;
  while (cin >> n) {
    memset(dp, 0, sizeof(dp));
    for (int i(1); i <= n; i++) {
      cin >> a[i];
    }
    a[0] = 0;
    a[n + 1] = 1001;
    for (int i(1); i <= n + 1; i++) {
      if (a[i] == a[i - 1] + 1) {
        dp[i] = dp[i - 1] + 1;
      } else
        dp[i] = 0;
    }
    int t = *max_element(dp, dp + n + 2) - 1;
    cout << (t > 0 ? t : 0) << endl;
  }
  return 0;
}
