#include <bits/stdc++.h>
using namespace std;
int q, x, y, m, idx, ms, idxs;
bool ch;
int r[400001];
int main() {
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  cin >> q >> x;
  for (int i = 1; i <= q; i++) {
    cin >> y;
    ++r[y % x];
    if (y % x == idxs) {
      m = r[0];
      idx = (idxs == x - 1 ? 0 : idxs);
      ch = false;
      for (int j = idx; j < x; j++) {
        if (m > r[j]) {
          idx = j;
          m = r[j];
          ch = true;
        }
      }
      if (!ch) idx = 0;
      ms = m, idxs = idx;
    }
    cout << idxs + ms * x << '\n';
  }
}
