#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long int q, x;
  cin >> q >> x;
  vector<long long int> query;
  for (long long int i = 0; i < q; i++) {
    long long int temp;
    cin >> temp;
    query.push_back(temp);
  }
  vector<long long int> v(x);
  long long int min_count = 400000;
  long long int val = 10000000;
  for (long long int i = 0; i < q; i++) {
    long long int t = query[i];
    v[t % x]++;
  }
  for (long long int i = 0; i < x; i++) {
    if (v[i] < min_count) {
      val = i;
      min_count = v[i];
    }
  }
  vector<long long int> answ;
  answ.push_back(x * min_count + val);
  for (long long int i = q - 1; i >= 0; i--) {
    long long int t = query[i];
    if (v[t % x] - 1 < min_count ||
        (v[t % x] - 1 == min_count && t % x < val)) {
      min_count = v[t % x] - 1;
      val = t % x;
    }
    v[t % x]--;
    answ.push_back(x * min_count + val);
  }
  for (long long int i = answ.size() - 2; i >= 0; i--) cout << answ[i] << endl;
}
