#include <bits/stdc++.h>
using namespace std;
map<int, bool> m;
int main() {
  ios::sync_with_stdio(0);
  int t, x;
  cin >> t >> x;
  int n, ans = 0;
  while (t--) {
    cin >> n;
    if (n == ans) {
      m[ans] = true;
      while (m[ans]) ans++;
      cout << ans << endl;
      continue;
    }
    int d = abs(ans - n);
    if (d % x == 0) {
      m[ans] = true;
      while (m[ans]) ans++;
    } else {
      int z = d / x;
      n -= z * x;
      if (!m[n]) {
        m[n] = true;
      }
      while (n < ans && m[n] == true) n += x;
      while (n > ans && m[n] == true) n -= x;
      m[n] = true;
    }
    cout << ans << endl;
  }
}
