#include <bits/stdc++.h>
using namespace std;
long long limit = 4294967296;
int MOD = 1000000007;
template <typename T>
void print(const T& x) {
  cerr << x << ' ';
}
template <typename T1, typename... T2>
void print(const T1& first, const T2&... rest) {
  print(first);
  print(rest...);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, x;
  cin >> n >> x;
  vector<pair<long long, int> > query;
  map<int, long long> m;
  set<int> res;
  for (int i = 0; i < n; i++) {
    long long temp;
    cin >> temp;
    long long q = temp / x;
    temp = temp - (q * x);
    query.push_back(make_pair(temp, i));
  }
  sort(query.begin(), query.end());
  m[query[0].second] = query[0].first;
  long long current = query[0].first;
  for (int i = 1; i < query.size(); i++) {
    if (current == query[i].first) {
      query[i].first = query[i - 1].first + x;
      m[query[i].second] = query[i].first;
    } else {
      m[query[i].second] = query[i].first;
      current = query[i].first;
    }
  }
  int pos = 0;
  for (auto it : m) {
    res.insert(it.second);
    while (res.count(pos)) pos++;
    cout << pos << endl;
  }
  return 0;
}
