#include <bits/stdc++.h>
using namespace std;
int main() {
  int num;
  int k;
  int output = 0;
  int temp = 0;
  int pre = 0;
  cin >> pre;
  for (int i = 1; i < num; i++) {
    int now = 0;
    cin >> now;
    if (abs(now - pre) == k) {
      temp++;
    } else {
      output = max(output, temp);
    }
    pre = now;
  }
  cout << output;
  return 0;
}
