#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int arr[105];
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  int cntr = 0, mx = 0;
  if (n > 1 && (arr[1] == 2)) mx = max(++cntr, mx);
  for (int i = 1; i < n - 1; ++i) {
    if (arr[i] == arr[i - 1] + 1 && arr[i] == arr[i + 1] - 1)
      mx = max(++cntr, mx);
    else
      cntr = 0;
  }
  if (n > 1 && (arr[n - 2] == 1e3 - 1)) mx = max(++cntr, mx);
  cout << mx << endl;
  return 0;
}
