#include <bits/stdc++.h>
using namespace std;
vector<int> t(1700001, 0);
vector<int> a(400001, 0);
int find(int i, int l, int r, int left, int right) {
  if (l > r) return 0;
  if (l == left && r == right) return t[i];
  if (r <= ((left + right) >> 1)) {
    return find(i * 2, l, r, left, ((left + right) >> 1));
  } else if (l > ((left + right) >> 1))
    return find(i * 2 + 1, l, r, ((left + right) >> 1) + 1, right);
  else {
    int leftindex =
        find(i * 2, l, ((left + right) >> 1), left, ((left + right) >> 1));
    int rightindex = find(i * 2 + 1, ((left + right) >> 1) + 1, r,
                          ((left + right) >> 1) + 1, right);
    if (a[leftindex] <= a[rightindex])
      return leftindex;
    else
      return rightindex;
  }
}
int update(int i, int l, int r, int left, int right) {
  if (l > r) return 0;
  if (left == l && right == r) {
    t[i] = l;
    a[l]++;
    return t[i];
  }
  if (r <= ((left + right) >> 1))
    update(i << 1, l, r, left, ((left + right) >> 1));
  else if (l > ((left + right) >> 1))
    update((i << 1) | 1, l, r, ((left + right) >> 1) + 1, right);
  else {
    update(i << 1, l, ((left + right) >> 1), left, ((left + right) >> 1));
    update(i * 2 + 1, ((left + right) >> 1) + 1, r, ((left + right) >> 1) + 1,
           right);
  }
  if (a[t[i * 2]] <= a[t[i * 2 + 1]])
    t[i] = t[i * 2];
  else
    t[i] = t[i * 2 + 1];
  return t[i];
}
int main() {
  int q, x, y, ans, maxvalue, maxf;
  cin >> q >> x;
  maxf = -1, maxvalue = -1;
  while (q--) {
    cin >> y;
    update(1, y % x, y % x, 0, x);
    maxf = max(maxf, a[y % x]);
    maxvalue = max(maxvalue, y % x);
    ans = find(1, 0, x, 0, x);
    if (ans == maxvalue) {
      if (maxvalue < x - 1)
        ans = maxvalue + 1;
      else
        ans = x * maxf;
    } else
      ans = x * a[ans] + ans;
    cout << ans << endl;
  }
  return 0;
}
