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