#include <bits/stdc++.h>
using namespace std;
long long arr[2000000] = {0}, brr[2000000] = {0};
vector<long long> vec;
string str;
long long mod = 1000000007;
map<long long, long long> mp;
set<long long> st;
stack<long long> stk;
long long fac(long long n) {
  long long i, prod = 1;
  for (i = 1; i <= n; i++) prod = ((i % mod) * (prod % mod)) % mod;
  return prod;
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
int main() {
  long long x, y, i, j, k, n, m, num, temp, fn,
      cnt = 0, d, l, r, flag = 0, sum1 = 0, a, b, len1 = 0, t, mx = LLONG_MIN,
      mn = LLONG_MAX, ind;
  long long x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;
  scanf("%lld %lld", &t, &x);
  num = 0;
  st.insert(0);
  while (t--) {
    scanf("%lld", &y);
    if (y == num || abs(y - num) % x == 0) {
      set<long long> tempset;
      for (auto kv : st) tempset.insert(kv);
      for (auto kv : st) {
        if (kv != num) break;
        tempset.erase(kv);
        num++;
      }
      st.clear();
      for (auto kv : tempset) st.insert(kv);
      st.insert(num);
    } else if (y > num) {
      st.insert(y - ((y - num) / x) * x);
    } else
      st.insert(y + ((num - y) / x + 1) * x);
    printf("%lld\n", num);
  }
  return 0;
}
