#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000005;
const long long INFLL = 1000000000000000002ll;
const long long MOD = 1000000007;
inline long long min(long long a, long long b, long long c) {
  return min(min(a, b), c);
}
inline long long min(long long a, long long b, long long c, long long d) {
  return min(min(min(a, b), c), d);
}
inline long long max(long long a, long long b, long long c) {
  return max(max(a, b), c);
}
inline long long max(long long a, long long b, long long c, long long d) {
  return max(max(max(a, b), c), d);
}
int A[1005], N;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> N;
  for (int i = (1); i <= (N); i++) cin >> A[i];
  A[N + 1] = 1001;
  int hi = 0;
  int ans = 0;
  for (int i = (1); i <= (N); i++)
    for (int j = (i); j <= (N); j++) {
      int r = j + 1;
      int l = i - 1;
      if (A[r] - A[l] == r - l) ans = max(ans, j - i + 1);
    }
  cout << ans;
}
