#include <bits/stdc++.h>
using namespace std;
const int INFL = (int)1e9;
const long long int INFLL = (long long int)1e18;
const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
bool nearlyeq(double x, double y) { return abs(x - y) < 1e-9; }
bool inrange(int x, int t) { return x >= 0 && x < t; }
long long int rndf(double x) {
  return (long long int)(x + (x >= 0 ? 0.5 : -0.5));
}
long long int floorsqrt(double x) {
  long long int m = (long long int)sqrt(x);
  return m + (m * m <= (long long int)(x) ? 0 : -1);
}
long long int ceilsqrt(double x) {
  long long int m = (long long int)sqrt(x);
  return m + ((long long int)x <= m * m ? 0 : 1);
}
long long int rnddiv(long long int a, long long int b) {
  return (a / b + (a % b * 2 >= b ? 1 : 0));
}
long long int ceildiv(long long int a, long long int b) {
  return (a / b + (a % b == 0 ? 0 : 1));
}
long long int gcd(long long int m, long long int n) {
  if (n == 0)
    return m;
  else
    return gcd(n, m % n);
}
int main() {
  int n;
  cin >> n;
  vector<long long int> a(n + 2, 0);
  for (int i = 1; i <= (int)n; i++) cin >> a[i];
  a[n + 1] = 1001;
  int ans = 0;
  int cnt = 1;
  for (int i = 1; i <= (int)n + 1; i++) {
    if (a[i] == a[i - 1] + 1) {
      cnt++;
    } else {
      ans = max(ans, cnt - 2);
      cnt = 1;
    }
  }
  ans = max(ans, cnt - 2);
  cout << ans << endl;
}
