#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 = 0, pos;
  cin >> t;
  ++num[t % b];
  if (t % b == 0) {
    pos = 1;
    cout << "1" << endl;
    min = 0;
  } else {
    pos = 0;
    cout << "0" << endl;
  }
  --a;
  while (a--) {
    cin >> t;
    ++num[t % b];
    if (t % b == pos) {
      min = 2000000000;
      for (int i = 0; i < b; ++i) {
        if (min > num[i]) {
          min = num[i];
          pos = 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;
}
