#include <bits/stdc++.h>
std::mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());
using namespace std;
int n, x, a[400001], b[400001], m;
set<int> s;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> x;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] %= x;
  }
  for (int i = 0; i < x; i++) {
    b[i] = i;
    s.insert(i);
  }
  for (int i = 0; i < n; i++) {
    m = a[i] % x;
    b[m] += x;
    a[i] = b[m] - x;
    s.erase(a[i]);
    s.insert(b[m]);
    cout << *s.begin() << '\n';
  }
  return 0;
}
