#include <bits/stdc++.h>
using namespace std;
int main() {
  int ans = 0, b = 0, i;
  int n;
  cin >> n;
  int a[1005];
  a[0] = 0;
  for (i = 1; i <= n; i++) cin >> a[i];
  a[i] = 1001;
  for (i = 1; i <= n; i++)
    (a[i - 1] + 1 == a[i] && a[i] + 1 == a[i + 1]) ? b++ : b = 0, ans > b
                                                                      ? ans += 0
                                                                      : ans = b;
  cout << ans << endl;
  return 0;
}
