#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const int N = 4e5 + 4, mod = 1e9 + 7;
int n, x, ans = -1, a[N], tree[N];
bool full[N];
set<int> pos[N];
void update(int k) {
  while (k < N) {
    tree[k]++;
    k += k & -k;
  }
}
int query(int k) {
  if (k < 1) {
    return 0;
  }
  int ans = 0;
  while (k >= 1) {
    ans += tree[k];
    k -= k & -k;
  }
  return ans;
}
int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin >> n >> x;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  if (x > n) {
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      full[a[i]] = 1;
      while (full[ans]) {
        ans++;
      }
      cout << ans << '\n';
    }
    return 0;
  }
  for (int i = 0; i < x; i++) {
    for (int j = 0; j <= n / x; j++) {
      if (i + j * x > n) {
        break;
      }
      pos[i].insert(i + j * x);
    }
  }
  for (int i = 1; i <= n; i++) {
    a[i] %= x;
    auto k = pos[a[i]].begin();
    if (k != pos[a[i]].end()) {
      update(*k + 1);
      pos[a[i]].erase(k);
    }
    int ans = -1;
    for (int j = 18; j >= 0; j--) {
      ans += 1 << j;
      if (query(ans + 1) < ans + 1) {
        ans -= 1 << j;
      }
    }
    cout << ans + 1 << '\n';
  }
}
