#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long q, x;
  cin >> q >> x;
  long long arr[q];
  map<long long, set<long long> > mp;
  vector<long long> v(q, 0);
  for (long long i = 0; i < q; i++) {
    cin >> v[i];
    mp[v[i] % x].insert(i);
  }
  long long ans = 0;
  for (long long j = 0; j < q; j++) {
    long long z = j % x;
    set<long long>::iterator it;
    it = mp[z].begin();
    if (it != mp[z].end()) {
      v[*it] = j;
      ans = j;
      mp[z].erase(it);
    } else {
      break;
    }
  }
  set<long long> p;
  for (long long i = 0; i < q; i++) {
    p.insert(v[i]);
  }
  ans = 0;
  set<long long>::iterator it1;
  long long c = 0;
  for (it1 = p.begin(); it1 != p.end(); it1++) {
    if (*(it1) != c) {
      break;
    }
    c++;
  }
  ans = c;
  vector<long long> a;
  for (long long i = q - 1; i >= 0; i--) {
    a.push_back(ans);
    if (v[i] < ans) {
      ans = v[i];
    }
  }
  for (long long i = a.size() - 1; i >= 0; i--) {
    cout << a[i] << endl;
  }
}
