#include <bits/stdc++.h>
using namespace std;
struct node {
  int ind;
  int qty;
};
bool operator<(const node& a, const node& b) {
  if (a.qty == b.qty) return a.ind < b.ind;
  return a.qty < b.qty;
}
int main() {
  int q, x;
  cin >> q >> x;
  set<node> ss;
  for (int i = 0; i < x; i++) ss.insert({i, 0});
  map<int, int> mp;
  while (q--) {
    int n;
    cin >> n;
    int ind1 = n % x;
    int qty1 = mp[ind1];
    ss.erase(ss.find({ind1, qty1}));
    ss.insert({ind1, qty1 + 1});
    mp[ind1] = qty1 + 1;
    node ans = *ss.begin();
    cout << ans.qty * x + ans.ind << endl;
  }
  return 0;
}
