#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  ;
  int t = 1;
  while (t--) {
    long long n, i, j, k, x, y, z, w, t1, t2, t3, ans = 0;
    cin >> n;
    vector<long long> v(n, 0);
    for (i = 0; i < n; i++) cin >> v[i];
    v.insert(v.begin(), 0);
    v.push_back(1001);
    x = 0;
    for (i = 1; i <= n; i++) {
      if (v[i] == v[i - 1] + 1 && v[i] + 1 == v[i + 1])
        x++;
      else {
        ans = max(ans, x);
        x = 0;
      }
    }
    ans = max(ans, x);
    cout << ans << "\n";
  }
  return 0;
}
