#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 10, mod = 1e9 + 7;
int q, n;
struct tr {
  int idx, val;
} tree[N << 4];
void build(int x = 1, int l = 0, int r = n - 1) {
  if (l == r) {
    tree[x].idx = l;
    tree[x].val = 0;
    return;
  }
  int mid = (l + r) >> 1;
  build(x << 1, l, mid);
  build(x << 1 | 1, mid + 1, r);
}
void upd(int i, int x = 1, int l = 0, int r = n - 1) {
  if (l == r) {
    tree[x].val++;
    return;
  }
  int mid = (l + r) >> 1;
  if (i <= mid)
    upd(i, x << 1, l, mid);
  else
    upd(i, x << 1 | 1, mid + 1, r);
  if (tree[x << 1].val <= tree[x << 1 | 1].val)
    tree[x] = tree[x << 1];
  else
    tree[x] = tree[x << 1 | 1];
}
int main() {
  scanf("%d%d", &q, &n);
  build();
  for (int i = 0; i < q; i++) {
    int y;
    scanf("%d", &y);
    y %= n;
    upd(y);
    int ans = tree[1].idx + n * tree[1].val;
    printf("%d\n", ans);
  }
  return 0;
}
