#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
void solve() {
  long long int n;
  cin >> n;
  long long int a[n + 2], cnt = 0, ok = 0, ans = 0;
  a[0] = 0;
  for (int(i) = (1); (i) < (n + 1); ++(i)) cin >> a[i];
  a[n + 1] = 1001;
  for (int(i) = (1); (i) < (n + 2); ++(i)) {
    if (a[i] - a[i - 1] == 1)
      cnt += 1, ok = 1;
    else if (ok) {
      cnt -= 1, ok = 0;
      ans = max(ans, cnt);
      cnt = 0;
    }
  }
  if (ok) cnt -= 1, ans = max(ans, cnt);
  ans = max(ans, cnt);
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  solve();
  return 0;
}
