#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, t;
  cin >> a >> b;
  int num[b + 5];
  memset(num, 0, sizeof(num));
  int min;
  while (a--) {
    cin >> t;
    ++num[t % b];
    if (min == num[t % b] - 1) {
      int temp = min;
      min = 2000000000;
      for (int i = 0; i < b; ++i) {
        if (temp == num[i]) {
          min = temp;
          break;
        }
        min = min < num[i] ? min : num[i];
      }
    }
    int f;
    for (int i = 0; i < b; ++i) {
      if (num[i] - min <= 0) {
        f = i;
        break;
      }
    }
    cout << min * b + f << endl;
  }
  return 0;
}
