#include <bits/stdc++.h>
const int Z = (int)4e5 + 123;
const int inf = (int)1e9 + 123;
const long long llinf = (long long)1e18 + 123;
using namespace std;
map<long long, int> need;
map<long long, long long> last;
int main() {
  long long q, d;
  cin >> q >> d;
  long long ind = 0;
  while (q--) {
    long long x, now = 0;
    cin >> x;
    if ((x - ind) % d == 0) {
      now = ind;
      now = max(now, last[x % d]);
      while (need[now] == 1) {
        now += d;
      }
      need[now] = 1;
      while (need[ind] == 1) ind++;
    } else {
      x %= d;
      now = x + (ind / d) * d;
      now = max(now, last[x % d]);
      while (need[now] == 1) now += d;
      need[now] = 1;
    }
    cout << ind << "\n";
    last[x % d] = now;
  }
  return 0;
}
