#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline void mine(T1 &x, const T2 &y) {
  if (y < x) x = y;
}
template <typename T1, typename T2>
inline void maxe(T1 &x, const T2 &y) {
  if (x < y) x = y;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &b) {
  for (auto &k : b) os << k << ' ';
  return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &b) {
  for (auto &k : b) is >> k;
  return is;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long N = 5e5;
long long cnt[N];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, x;
  cin >> n >> x;
  set<pair<long long, long long> > have;
  for (long long i = 0; i < x; i++) {
    have.insert({0, i});
  }
  while (n--) {
    long long y;
    cin >> y;
    long long r = y % x;
    have.erase({cnt[r], r});
    ++cnt[r];
    have.insert({cnt[r], r});
    long long c = have.begin()->first;
    r = have.begin()->second;
    cout << c * x + r << '\n';
  }
}
