#include <bits/stdc++.h>
using namespace std;
set<long long> s;
long long q, x;
long long d[400001];
int main() {
  cin >> q >> x;
  for (long long i = 0; i <= x; i++) s.insert(i);
  while (q--) {
    long long y;
    cin >> y;
    y %= x;
    s.erase(y + x * d[y]);
    d[y]++;
    s.insert(y + (x * d[y]));
    if (s.size() == 0) {
      cout << 0 << "\n";
      continue;
    }
    cout << *(s.begin()) << "\n";
  }
  return 0;
}
