#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int q, x;
  cin >> q >> x;
  set<int> s;
  for (int i = 0; i <= 400005; i++) {
    s.insert(i);
  }
  int count[x + 1];
  for (int i = 0; i < x + 1; i++) count[i] = 0;
  while (q--) {
    int n;
    cin >> n;
    n = n % x;
    int temp = count[n] * x + n;
    count[n]++;
    if (s.find(temp) != s.end()) s.erase(s.find(temp));
    auto it = s.begin();
    cout << *it << endl;
  }
}
