#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long i, j, k = 0, n, t = 1, m, l = 0;
  long long x;
  cin >> t >> x;
  map<long long, long long> mp;
  set<pair<long long, long long>> s;
  for (i = 0; i < x; i++) {
    s.insert({0, i});
  }
  while (t--) {
    cin >> n;
    m = n % x;
    auto it = s.find({mp[m], m});
    s.erase(it);
    mp[m]++;
    s.insert({mp[m], m});
    it = s.begin();
    long long ff = (*it).first;
    long long ss = (*it).second;
    cout << ss + ff * x << "\n";
  }
  return 0;
}
