#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[1005], i, j, k, m, l, r, ll, rr;
  while (~scanf("%d", &n)) {
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    k = m = 0;
    for (i = 0; i < n - 1; i++) {
      if (a[i] + 1 == a[i + 1]) {
        if (k == 0) {
          k = 2;
          ll = a[i];
          if (i == 0 && a[i] == 1) k++;
        } else
          k++;
        if (i + 1 == n - 1 && a[n - 1] == 1000) k++;
        rr = a[i + 1];
      } else
        k = 0;
      m = max(k, m);
    }
    m = max(m, 2);
    printf("%d\n", m - 2);
  }
  return 0;
}
