#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  ;
  long long ans, ans2, q, x;
  cin >> q >> x;
  ans = 0;
  long long arr[x];
  memset(arr, 0, sizeof(arr));
  long long d;
  cin >> d;
  arr[d % x]++;
  long long co = 0;
  while (arr[ans] != 0) {
    arr[ans]--;
    ans++;
    if (ans == x) {
      ans = 0;
      co++;
    }
  }
  if (d == 0)
    cout << 1 << endl;
  else
    cout << 0 << endl;
  q--;
  while (q--) {
    cin >> d;
    arr[d % x]++;
    while (arr[ans] != 0) {
      arr[ans]--;
      ans++;
      if (ans == x) {
        co++;
        ans = 0;
      }
    }
    cout << co * x + (ans) << endl;
  }
}
