#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long q, n;
  cin >> q >> n;
  long long arr[n];
  for (long long i = 0; i < n; ++i) arr[i] = 0;
  long long point = 0;
  long long time = 1;
  while (q--) {
    long long temp;
    cin >> temp;
    arr[temp % n]++;
    if (arr[point] >= time) {
      while (arr[point] >= time) {
        point++;
        if (point == n) {
          time++;
          point = 0;
        }
      }
    }
    cout << (time - 1) * n + point << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  long long t = 1;
  while (t--) solve();
}
