#include <bits/stdc++.h>
using namespace std;
map<long long int, long long int> seen;
double conv(double a, double d, double sum) {
  double ans = (sum - a + d) / d;
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long int n, q, x;
  cin >> q >> x;
  int ans = 0;
  while (q--) {
    cin >> n;
    if (abs(n - ans) % x == 0) {
      seen[ans] = 1;
      ans++;
    } else if (n < ans) {
      double ans11 = conv(n, n + abs(n - ans), x);
      long long int ok = floor(ans11);
      long long int one = n - ((ok - 1) * x);
      long long int two = n + ((ok + 1) * x);
      long long int three = n - (ok * x);
      long long int four = n + (ok * x);
      long long int six = n + ((ok - 1) * x);
      long long int five = n - ((ok + 1) * x);
      long long int mn = 10000000000000000;
      if (one >= ans) mn = min(mn, one);
      if (two >= ans) mn = min(mn, two);
      if (three >= ans) mn = min(mn, three);
      if (four >= ans) mn = min(mn, four);
      if (five >= ans) mn = min(mn, five);
      if (six >= ans) mn = min(mn, six);
      seen[mn] = 1;
    } else
      seen[n] = 1;
    while (seen[ans]) ans++;
    cout << ans << endl;
  }
  return 0;
}
