#include <bits/stdc++.h>
using namespace std;
long long int n, x, p, z, r, m;
long long int y[400000] = {0};
long long int *il;
int main() {
  cin >> n >> p;
  while (n) {
    cin >> x;
    y[x % p]++;
    il = min_element(y, y + p - 1);
    z = 0;
    while (y[z] > *il && z < p) z++;
    r = *il;
    m = p * r + z;
    cout << z << "\n";
    n--;
  }
  return 0;
}
