#include <bits/stdc++.h>
using namespace std;
int A[105];
int N;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
  }
  int Ans = 0;
  int Max = 0;
  for (int i = 1; i <= N; i++) {
    if (i == 1 && N > 1) {
      if (A[i + 1] == 2) Ans++;
    } else if (i > 1 && i < N) {
      if (A[i - 1] == A[i] - 1 && A[i + 1] == A[i] + 1)
        Ans++;
      else
        Ans = 0;
    } else if (i == N && N > 1) {
      if (A[i - 1] == 999)
        Ans++;
      else
        Ans = 0;
    }
    Max = max(Max, Ans);
  }
  cout << Max << '\n';
  return 0;
}
