#include <bits/stdc++.h>
using namespace std;
inline void pin(int n) { printf("%d\n", n); }
double PI = acos(-1);
const int inf = 0x3f3f3f3f;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int q, x;
  cin >> q >> x;
  vector<int> p(q);
  for (int i = 0; i < q; ++i) {
    cin >> p[i];
  }
  vector<int> nex(x, 0);
  for (int i = 0; i < x; i++) {
    nex[i] = i;
  }
  vector<int> marker(400005, 0);
  int cmex = 0;
  for (int i = 0; i < q; ++i) {
    int ch = p[i];
    if (ch >= 0 && ch < x)
      ;
    else {
      int a = ceil((double(ch) - x) / x);
      ch -= a * x;
      if (ch == x) ch = 0;
    }
    if (nex[ch] >= 400005) continue;
    marker[nex[ch]] = 1;
    nex[ch] += x;
    while (marker[cmex] != 0) {
      cmex++;
    }
    cout << cmex << endl;
  }
  return 0;
}
