#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[102], n, count = 0, i, max_count;
  cin >> n;
  a[0] = 0;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
  }
  a[n + 1] = 1001;
  if (n == 1) {
    cout << "0";
  } else {
    count = 0;
    max_count = INT_MIN;
    for (i = 1; i <= n; i++) {
      if (a[i - 1] + 1 == a[i] && a[i] + 1 == a[i + 1])
        count++;
      else {
        if (max_count < count) max_count = count;
        count = 0;
      }
    }
    if (max_count < count) max_count = count;
    cout << max_count;
  }
}
