#include <bits/stdc++.h>
using namespace std;
long long int q, x, y, curr;
vector<long long int> arr;
set<long long int> st1, st2;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> q >> x;
  for (int i = 0; i <= q; i++) {
    st1.insert(i);
    st2.insert(i);
  }
  while (q--) {
    cin >> y;
    long long int tar = *st1.begin();
    long long int diff = abs(y - tar);
    long long int mul = ceil((double)diff / (double)x);
    if (st1.find(y) == st1.end()) {
      long long int a = y + mul * x;
      long long int b = y - mul * x;
      if (b < 0 || st1.find(b) == st1.end())
        y = a;
      else
        y = b;
    }
    st1.erase(y);
    arr.push_back(y);
  }
  for (auto x : arr) {
    st2.erase(x);
    long long int ans = *st2.begin();
    cout << ans << endl;
  }
  return 0;
}
