#include <bits/stdc++.h>
using namespace std;
map<int, int> vis;
int main() {
  int T, x, i = 0;
  std::cin >> T >> x;
  while (T--) {
    int n;
    std::cin >> n;
    if ((n - i) % 3 == 0)
      vis[i] = 1;
    else if (vis[n] == 0)
      vis[n] = 1;
    else {
      while (vis[n + x] == 1) n += x;
      vis[n + x] = 1;
    }
    while (vis[i]) {
      i++;
    }
    std::cout << i << endl;
  }
  return 0;
}
