#include <bits/stdc++.h>
using namespace std;
const long long INF = LLONG_MAX;
const long long SIZE = 4e5 + 5;
const long long mod = 1e9 + 7;
unordered_map<long long, bool> m;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 0, n, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0;
  string s, s1, s2;
  set<long long> stt;
  cin >> q >> p;
  for (i = 0; i < q + 2; i++) stt.insert(i);
  while (q--) {
    cin >> x;
    x %= p;
    long long st = 0, en = 4e4;
    if (!m[x]) {
      m[x] = 1;
      stt.erase(x);
      ans = *stt.begin();
      cout << ans << "\n";
      continue;
    }
    ans = 0;
    while (st <= en) {
      long long mid = (st + en) / 2;
      y = (p * mid) + x;
      if (!m[y]) {
        ans = y;
        en = mid - 1;
      } else
        st = mid + 1;
    }
    m[ans] = 1;
    stt.erase(ans);
    ans = *stt.begin();
    cout << ans << "\n";
  }
  return 0;
}
