#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int k;
int cut[400005];
int ans;
int s;
void solve() {
  int t;
  cin >> t;
  cut[t % k]++;
  while (cut[ans % k]) {
    cut[ans % k]--;
    ans++;
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  int q;
  cin >> q >> k;
  ans = 0;
  for (s = 1; s <= q; s++) {
    solve();
  }
}
