#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int maxx = 0, start = 0, end = 0, ans = 0;
  int i, j;
  for (i = 0; i < n; i++) {
    int c = 0;
    for (j = i + 1; j < n; j++) {
      if (arr[j] - 1 == arr[j - 1]) {
        c++;
        end = j;
      } else
        break;
    }
    c++;
    start = i;
    if (arr[start] == 1) c++;
    if (arr[end] == 1000) c++;
    ans = max(ans, c - 2);
  }
  cout << ans;
}
