#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[201];
  for (int i = 1; i <= n; ++i) cin >> arr[i];
  int brr[201] = {0}, count = 0;
  for (int i = 1; i <= n; ++i) {
    if (i == 1 && n >= 2) {
      if (arr[1] == 1 && arr[2] == 2) brr[i] = 1;
    } else {
      if (i == n && n >= 2) {
        if (arr[n] == 1000 && arr[n - 1] == 999) brr[i] = 1;
      } else {
        if (arr[i - 1] == arr[i] - 1 && arr[i + 1] == arr[i] + 1) brr[i] = 1;
      }
    }
  }
  int t = 0;
  for (int i = 1; i <= n;) {
    while (i <= n && brr[i] == 1) {
      t++;
      i++;
    }
    while (i <= n && brr[i] == 0) {
      i++;
    }
    count = max(count, t);
    t = 0;
  }
  cout << count << endl;
}
