#include <bits/stdc++.h>
using namespace std;
const long long N = 5e5 + 1, inf = 1e9;
long long cnt[N];
set<pair<long long, long long> > s;
signed main() {
  long long q, x, e;
  cin >> q >> x;
  for (long long i = 0; i < x; i++) s.insert({0, i});
  for (long long i = 0; i < q; i++) {
    cin >> e;
    s.erase({cnt[e % x], e % x});
    cnt[e % x]++;
    s.insert({cnt[e % x], e % x});
    e = (s.begin()->first) * x + s.begin()->second;
    cout << e << endl;
  }
}
