#include <bits/stdc++.h>
using namespace std;
int q, x, cnt[800001], res;
int main() {
  scanf("%d %d", &q, &x);
  while (q--) {
    int i;
    scanf("%d", &i);
    cnt[i % x]++;
    while (cnt[(res + 1) % x] < cnt[res] ||
           (cnt[(res + 1) % x] == cnt[res] && (res + 1) % x < res))
      res = (res + 1) % x;
    printf("%d\n", x * cnt[res] + res);
  }
  return 0;
}
