#include <bits/stdc++.h>
using ll = long long;
const ll mod = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
using namespace std;
using vl = vector<ll>;
using pll = pair<ll, ll>;
void answer() {
  ll n, ans = 0, m, p = 0, x;
  cin >> n >> p;
  m = p;
  std::set<ll> s;
  for (int i = 0; i <= n; i++) s.insert(i);
  vector<ll> v(n + 1);
  int y;
  while (n--) {
    cin >> y;
    if (*s.begin() == y) {
      s.erase(y);
      cout << *s.begin() << "\n";
    } else {
      v[y % m]++;
      x = v[y % m] * m + y % m;
      s.erase(x);
      cout << *s.begin() << "\n";
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int q;
  answer();
  return 0;
}
