#include <bits/stdc++.h>
using namespace std;
int v[105];
int main() {
  int n, i, cnt = 0, cntmax = -1;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> v[i];
  v[i] = 1001;
  for (i = 1; i <= n; i++) {
    if (v[i] == v[i - 1] + 1 && v[i] == v[i + 1] - 1)
      cnt++;
    else {
      if (cnt > cntmax) cntmax = cnt;
      cnt = 0;
    }
  }
  if (cnt > cntmax) cntmax = cnt;
  cout << cntmax;
  return 0;
}
