#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int MAXN = 1e6 + 5, inf = 1e9;
const ll INF = 1e18;
const ld PI = 3.1415926535897932384626433832795;
int cnt[MAXN];
ll dp[MAXN], tab[MAXN];
bool vis[MAXN], used[MAXN];
vector<int> G[MAXN];
vector<ll> V;
set<ll> S;
map<ll, int> M;
stack<ll> St;
queue<ll> Q;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << setprecision(13) << fixed;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> tab[i];
  }
  tab[n + 1] = 1001;
  int res = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n + 1; j++) {
      bool ok = 1;
      for (int k = i; k <= j; k++) {
        if (tab[k] != tab[k - 1] + 1) {
          ok = 0;
          break;
        }
      }
      if (ok) res = max(res, j - i);
    }
  }
  cout << res << "\n";
}
