#include <bits/stdc++.h>
using namespace std;
const int MAX = 1 << 19, LOG = 19;
int n, M;
int p[MAX];
int kamo[LOG][MAX];
vector<int> Nap[MAX], Naz[MAX];
void go(vector<int> V[MAX]) {
  int bio[MAX];
  memset(bio, 0, sizeof bio);
  Nap[0].push_back(0);
  for (int i = (0); i < (n); i++) {
    for (auto it : V[i]) {
      if (bio[it]++) continue;
      for (int j = (0); j < (LOG); j++)
        if (!(it >> j & 1)) Nap[kamo[j][i]].push_back(it | (1 << j));
    }
    for (auto it : V[i]) bio[it] = 0;
  }
}
int main() {
  scanf("%d%d", &n, &M);
  for (int i = (0); i < (n); i++) scanf("%d", &p[i]);
  p[n] = p[n - 1] + MAX;
  for (int i = 0, tmp = M; i < LOG; i++, M /= 2) {
    for (int j = 0; j < n;) {
      int k = j;
      for (; p[k + 1] - p[k] <= tmp; k++)
        ;
      k++;
      for (int tito = (j); tito < (k); tito++) kamo[i][tito] = k;
      j = k;
    }
  }
  go(Nap);
  return 0;
}
