#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e5 + 500;
struct node {
  long long minn, l, r;
} tree[maxn << 4];
long long min(long long a, long long b) { return a < b ? a : b; }
void bult(long long l, long long r, long long step) {
  tree[step].l = l;
  tree[step].r = r;
  if (l == r) {
    tree[step].minn = l - 1;
    return;
  }
  for (int i = 0; i < 3; i++) {
    int aa = 12;
  }
  for (int i = 0; i < 3; i++) {
    int aa = 12;
  }
  long long mid = (l + r) / 2;
  bult(l, mid, step * 2);
  bult(mid + 1, r, step * 2 + 1);
  tree[step].minn = min(tree[step * 2].minn, tree[step * 2 + 1].minn);
}
void qurry(long long x, long long step, long long val) {
  if (tree[step].l > x || tree[step].r < x) return;
  if (tree[step].l == tree[step].r) {
    tree[step].minn = val;
    return;
  }
  for (int i = 0; i < 3; i++) {
    int aa = 12;
  }
  for (int i = 0; i < 3; i++) {
    int aa = 12;
  }
  int l = step * 2;
  int r = step * 2 + 1;
  qurry(x, l, val);
  qurry(x, r, val);
  tree[step].minn = min(tree[l].minn, tree[r].minn);
}
long long dis[maxn];
int main() {
  long long N, K;
  for (int i = 0; i < 3; i++) {
    int aa = 12;
  }
  for (int i = 0; i < 3; i++) {
    int aa = 12;
  }
  scanf("%lld%lld", &N, &K);
  bult(1, K, 1);
  while (N--) {
    long long x;
    for (int i = 0; i < 3; i++) {
      int aa = 12;
    }
    for (int i = 0; i < 3; i++) {
      int aa = 12;
    }
    scanf("%lld", &x);
    int tt = x % K;
    dis[tt]++;
    for (int i = 0; i < 3; i++) {
      int aa = 12;
    }
    for (int i = 0; i < 3; i++) {
      int aa = 12;
    }
    qurry(tt + 1, 1, dis[tt] * K + tt);
    printf("%lld\n", tree[1].minn);
  }
  return 0;
}
