#include <bits/stdc++.h>
using namespace std;
long long q, x, y;
int main() {
  cin >> q >> x;
  map<long long, long long> mp;
  long long minn = 0;
  while (q--) {
    cin >> y;
    if (y == minn) {
      mp[y] = 1;
    } else if (y < minn) {
      long long tmp = minn - y;
      tmp /= x;
      y += tmp * x;
      if (y < minn) y += x;
      mp[y] = 1;
    } else if (y > minn) {
      long long tmp = y - minn;
      tmp /= x;
      y -= tmp * x;
      if (y < minn) y += x;
      mp[y] = 1;
    }
    while (mp[minn] == 1) minn++;
    cout << minn << "\n\n";
  }
  return 0;
}
