#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int q, x, y, c;
  cin >> q >> x;
  vector<int> cnt(x, 0);
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      pq;
  for (int i = 0; i < x; i++) pq.push({0, i});
  for (int i = 0; i < q; i++) {
    cin >> y;
    y %= x;
    cnt[y]++;
    pq.push({cnt[y], y});
    while (pq.top().first < cnt[pq.top().second]) pq.pop();
    cout << pq.top().first * x + pq.top().second << '\n';
  }
  return 0;
}
