#include <bits/stdc++.h>
using namespace std;
long long n, a[105], Max = 0, dem;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  a[0] = 0;
  a[n + 1] = 1001;
  dem = 1;
  for (int i = 1; i <= n + 1; i++) {
    if (a[i] == a[i - 1] + 1) {
      dem++;
      Max = max(Max, dem - 2);
    } else
      dem = 1;
  }
  cout << Max;
}
