#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int INF = 1e9 + 7;
const int N = 4e5 + 7;
const int M = 5e6 + 7;
int vis[M], p[N];
signed main() {
  int q, x, y;
  scanf("%d", &q);
  scanf("%d", &x);
  int head = 0;
  for (int i = 0; i <= x; i++) p[i] = i;
  while (q--) {
    scanf("%d", &y);
    y %= x;
    if (y == head)
      vis[head] = 1;
    else {
      if (y > head && p[y] < M) {
        vis[p[y]] = 1;
        p[y] += x;
      } else {
        int k = (head - y) / x;
        if (y + k * x == head)
          vis[head] = 1;
        else if (p[y] < M) {
          vis[p[y]] = 1;
          p[y] += x;
        }
      }
    }
    while (p[y] < M && vis[p[y]]) p[y] += x;
    while (vis[head]) head++;
    printf("%d\n", head);
  }
  return 0;
}
