#include <bits/stdc++.h>
using namespace std;
int n = 10;
vector<bool> isFilled(n + 1, false);
int q, x;
int mex = 0;
int bs(int t) {
  int l = t, r = n - n % x + t;
  while (l < r) {
    int m = (((r - l) / x) / 2) * x + l;
    if (isFilled[m])
      l = m + x;
    else
      r = m;
  }
  return r;
}
void solve() {
  cin >> q >> x;
  for (int i = 0; i < q; ++i) {
    int y;
    cin >> y;
    int t = bs(y % x);
    isFilled[t] = true;
    while (isFilled[mex]) mex++;
    cout << mex << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T = 1;
  while (T--) solve();
  return 0;
}
