#include <bits/stdc++.h>
using namespace std;
int n, aa, res;
vector<int> a = {-2, 0};
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> aa;
    a.push_back(aa);
  }
  a.push_back(1e3 + 1);
  a.push_back(1e3 + 3);
  int cur = 0;
  for (int i = 1; i < (int)a.size(); i++) {
    if (a[i] - a[i - 1] > 1) {
      res = max(res, i - cur);
      cur = i;
    }
  }
  cout << max(0, res - 2);
  return 0;
}
