#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
#pragma GCC optimize(2)
% : pragma GCC optimize(3) % : pragma GCC optimize("Ofast") %
    : pragma GCC optimize("inline") % : pragma GCC optimize("-fgcse") %
    : pragma GCC optimize("-fgcse-lm") % : pragma GCC optimize("-fipa-sra") %
    : pragma GCC optimize("-ftree-pre") % : pragma GCC optimize("-ftree-vrp") %
    : pragma GCC optimize("-fpeephole2") %
    : pragma GCC optimize("-ffast-math") %
    : pragma GCC optimize("-fsched-spec") %
    : pragma GCC optimize("unroll-loops") %
    : pragma GCC optimize("-falign-jumps") %
    : pragma GCC optimize("-falign-loops") %
    : pragma GCC optimize("-falign-labels") %
    : pragma GCC optimize("-fdevirtualize") %
    : pragma GCC optimize("-fcaller-saves") %
    : pragma GCC optimize("-fcrossjumping") %
    : pragma GCC optimize("-fthread-jumps") %
    : pragma GCC optimize("-funroll-loops") %
    : pragma GCC optimize("-fwhole-program") %
    : pragma GCC optimize("-freorder-blocks") %
    : pragma GCC optimize("-fschedule-insns") %
    : pragma GCC optimize("inline-functions") %
    : pragma GCC optimize("-ftree-tail-merge") %
    : pragma GCC optimize("-fschedule-insns2") %
    : pragma GCC optimize("-fstrict-aliasing") %
    : pragma GCC optimize("-fstrict-overflow") %
    : pragma GCC optimize("-falign-functions") %
    : pragma GCC optimize("-fcse-skip-blocks") %
    : pragma GCC optimize("-fcse-follow-jumps") %
    : pragma GCC optimize("-fsched-interblock") %
    : pragma GCC optimize("-fpartial-inlining") %
    : pragma GCC optimize("no-stack-protector") %
    : pragma GCC optimize("-freorder-functions") %
    : pragma GCC optimize("-findirect-inlining") %
    : pragma GCC optimize("-fhoist-adjacent-loads") %
    : pragma GCC optimize("-frerun-cse-after-loop") %
    : pragma GCC optimize("inline-small-functions") %
    : pragma GCC optimize("-finline-small-functions") %
    : pragma GCC optimize("-ftree-switch-conversion") %
    : pragma GCC optimize("-foptimize-sibling-calls") %
    : pragma GCC optimize("-fexpensive-optimizations") %
    : pragma GCC optimize("-funsafe-loop-optimizations") %
    : pragma GCC optimize("inline-functions-called-once") %
    : pragma GCC optimize("-fdelete-null-pointer-checks") inline int read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
long long qpow(long long a, long long b, long long p) {
  long long ans = 1;
  a = a % p;
  while (b) {
    if (b & 1) ans = 1ll * ans * a % p;
    a = 1ll * a * a % p;
    b >>= 1;
  }
  return ans % p;
}
long long fun(long long a, long long b) {
  long long sum = 0;
  while (b) {
    a = a;
    b = b;
    if (1 & b) {
      sum = (sum + a);
    }
    b >>= 1;
    a = (a << 1);
  }
  return sum;
}
int gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
inline int min(int a, int b) { return a > b ? b : a; }
inline void write(long long x) {
  if (x > 9) write(x / 10);
  putchar(x % 10 + 48);
}
inline void writespace(long long x) {
  write(x);
  putchar(32);
  return;
}
inline void writeln(long long x) {
  write(x);
  putchar(10);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
const int maxn = 1e6 + 6;
int vis[2 * maxn];
long long num[maxn], n, m, p;
int main() {
  scanf("%lld%lld", &n, &m);
  int x;
  int mex = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &x);
    if (x > mex) {
      int diff = x - mex;
      int cir = diff / m;
      x += cir * m;
      while (vis[x]) x += m;
    } else {
      int diff = mex - x;
      int cir = (diff + m - 1) / m;
      x += cir * m;
      while (vis[x]) x += m;
    }
    long long l = 0, r = (1e6 - x + m - 1) / m;
    int ans = -1;
    while (l <= r) {
      int mid = (l + r) / 2;
      if (vis[x + mid * m])
        l = mid + 1;
      else {
        r = mid - 1;
        ans = mid;
      }
    }
    if (x + ans * m <= 1e6) vis[x + ans * m] = 1;
    while (vis[mex]) mex++;
    printf("%d\n", mex);
  }
}
