#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<long long> res;
  for (int i = 0; i < n; i++) {
    long long temp;
    cin >> temp;
    if (x == 1) {
      query.push_back(make_pair(temp, i));
      continue;
    }
    temp = temp % x;
    query.push_back(make_pair(temp, i));
  }
  sort(query.begin(), query.end());
  for (int i = 0; i < query.size(); i++)
    cout << query[i].first << " " << query[i].second << endl;
  m[query[0].second] = query[0].first;
  for (int i = 1; i < query.size(); i++) {
    if (query[i - 1].first - x == query[i].first ||
        query[i - 1].first == 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;
    }
  }
  int pos = 0;
  for (auto it : m) {
    res.insert(it.second);
    while (res.count(pos)) pos++;
    cout << pos << endl;
  }
  return 0;
}
