#include <bits/stdc++.h>
using namespace std;
long long has[1000005];
stack<long long> till;
void Solve() {
  long long q, x, mex = 0;
  set<long long> cur;
  cin >> q >> x;
  while (q--) {
    long long k;
    cin >> k;
    long long least = (k % x) + x * (mex / x);
    if (least == mex) {
      while (!till.empty()) {
        long long m = till.top(), mul = m;
        till.pop();
        for (long long i = 2; i <= has[m]; i++) {
          while (has[mul] && mul <= 400005) mul += x;
          has[mul]++;
        }
        has[m] = 1;
      }
      while (has[mex + 1]) mex++;
      mex++;
    }
    has[least]++;
    if (has[least] == 2) till.push(least);
    cout << mex << "\n";
  }
  return;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  Solve();
  return 0;
}
