#include <bits/stdc++.h>
using namespace std;
long long vis[400000 + 5];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long q, x;
  cin >> q >> x;
  long long tmp, round = 0, cnt = 0, pos = 0;
  while (q--) {
    cin >> tmp;
    tmp %= x;
    if (vis[tmp] == round) cnt++;
    vis[tmp]++;
    if (tmp == pos) {
      pos = 0;
      for (long long i = 0; i < x; i++) {
        if (vis[pos] == round) break;
        if (vis[i] < vis[pos]) pos = i;
      }
    } else if (vis[tmp] < vis[pos] || vis[tmp] == vis[pos] && tmp < pos) {
      pos = tmp;
    }
    if (cnt == x) {
      cnt = 0;
      round++;
    }
    cout << round * x + pos << "\n";
  }
  return 0;
}
