#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const double pi = 2 * asin(1);
const int MOD = 1000000007;
int abcd(int x) { return x + 1; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, x;
  cin >> n >> x;
  vector<int> rems(n);
  set<pair<int, int> > val;
  for (int i = 0; i < int(x); i++) val.insert(pair<int, int>(0, i));
  for (int i = 0; i < int(n); i++) rems[i] = 0;
  for (int i = 0; i < int(n); i++) {
    int cur;
    cin >> cur;
    cur = cur % x;
    val.erase(pair<int, int>(rems[cur], cur));
    rems[cur]++;
    val.insert(pair<int, int>(rems[cur], cur));
    int a, b;
    set<pair<int, int> >::iterator it;
    it = val.begin();
    a = (*it).first;
    b = (*it).second;
    cout << a * x + b << endl;
  }
}
