#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, m;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<long long int> v;
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i == 0 && a[i] == 1 && a[i + 1] == 2) {
      ans++;
    } else if (i == n - 1 && a[i] == 1000 && a[i - 1] == 999) {
      ans++;
    } else if (a[i + 1] - a[i] == 1 && a[i] - a[i - 1] == 1) {
      ans++;
    } else {
      v.push_back(ans);
      ans = 0;
    }
  }
  v.push_back(ans);
  cout << *max_element(v.begin(), v.end());
}
