#include <bits/stdc++.h>
using namespace std;
long long int z = 1000000009;
bool aya[400005];
long long int search(bool aya[], long long int *k, long long int q) {
  for (long long int i = *k; i <= q; i++) {
    if (aya[i] == false) {
      *k = i;
      break;
    }
  }
  return *k;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int q, x, y;
  cin >> q >> x;
  map<long long int, long long int> m;
  for (long long int i = 0; i < x; i++) {
    m[i] = i;
  }
  memset(aya, false, sizeof(aya));
  vector<long long int> v;
  long long int c = 0;
  long long int p = q;
  while (p--) {
    cin >> y;
    if (c == y) {
      aya[c] = true;
      m[c % x] = m[c % x] + x;
      v.push_back(search(aya, &c, q));
    } else if (c > y) {
      if (c % x == y % x) {
        aya[c] = true;
        m[y % x] = m[y % x] + x;
        v.push_back(search(aya, &c, q));
      } else {
        v.push_back(c);
        if (m[y % x] < q) {
          aya[m[y % x]] = true;
          m[y % x] = m[y % x] + x;
        }
      }
    } else {
      if (c % x == y % x) {
        aya[c] = true;
        m[y % x] = m[y % x] + x;
        v.push_back(search(aya, &c, q));
      } else {
        v.push_back(c);
        if (m[y % x] < q) {
          aya[m[y % x]] = true;
          m[y % x] = m[y % x] + x;
        }
      }
    }
  }
  for (long long int i = 0; i < q; i++) cout << v[i] << "\n";
}
