#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  ;
  int x[400005] = {0};
  int a, n, i, T, y, ans = 0, cnt = 0;
  cin >> n >> a;
  for (i = 0; i < n; i++) {
    cin >> y;
    x[y % a]++;
    while (true) {
      if (x[cnt % a] > cnt / a)
        cnt++;
      else {
        cout << cnt << "\n";
        break;
      }
    }
  }
}
