#include <bits/stdc++.h>
const int maxn = 4e5 + 5;
int a[maxn] = {};
using namespace std;
int main() {
  int q, k;
  cin >> q >> k;
  int ans = 0;
  int x;
  a[0] = 1;
  while (q--) {
    cin >> x;
    x %= k;
    a[x]++;
    while (a[ans % k] > 0) {
      a[ans % k]--;
      ans++;
    }
    cout << ans << endl;
  }
  return 0;
}
