#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;
  vector<int> v(p);
  int y;
  while (n--) {
    cin >> y;
    v[y % p]++;
    while (v[ans % p]) {
      v[ans % p]--;
      ans++;
    }
    cout << ans << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int q;
  answer();
  return 0;
}
