#include <bits/stdc++.h>
using namespace std;
struct info {
  int id, cnt;
};
info v[400005], s[400005];
int main() {
  int q, x, a, y, ans, i;
  info mn, ex;
  memset(v, 0, sizeof v);
  scanf("%d %d", &q, &x);
  for (i = 0; i < x; i++) v[i].id = i;
  mn.id = ex.id = 0;
  mn.cnt = INT_MAX / 4;
  ex.cnt = INT_MAX;
  while (q--) {
    scanf("%d", &a);
    y = a % x;
    v[y].cnt++;
    if (ex.cnt == v[mn.id].cnt) {
      mn.id = ex.id;
    }
    mn.cnt = INT_MAX / 4;
    for (i = mn.id; i < x; i++) {
      if (v[i].cnt < mn.cnt) {
        ex.id = mn.id;
        ex.cnt = mn.cnt;
        mn.cnt = v[i].cnt;
        mn.id = v[i].id;
      }
      if (mn.cnt == 0) break;
    }
    ans = mn.id + x * mn.cnt;
    printf("%d\n", ans);
  }
  return 0;
}
