#include <bits/stdc++.h>
using namespace std;
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  long long q, x, mex = 0, y;
  cin >> q >> x;
  set<long long> s;
  for (int i = 0; i < 500000; i++) s.insert(i);
  for (int qi = 0; qi < q; qi++) {
    cin >> y;
    long long st = 0, en = 1e6;
    long long z = y % x;
    while (st <= en) {
      long long mid = (st + en) / 2;
      if (s.find(z + x * mid) == s.end() && z + x * mid < 500000) {
        st = mid + 1;
      } else {
        en = mid - 1;
      }
    }
    set<long long>::iterator it = s.find(z + x * st);
    if (it != s.end()) s.erase(it);
    cout << *s.begin() << endl;
  }
  return 0;
}
