#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f3f3f3f3f;
long long power(long long a, long long b) {
  long long res = 1;
  while (b != 0) {
    if (b & 1) {
      res *= a;
    }
    a = (a * a);
    b = (b / 2);
  }
  return res;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t;
  t = 1;
  while (t--) {
    long long q, p, i;
    cin >> q >> p;
    set<long long> s;
    for (i = 0; i <= q; i++) {
      s.insert(i);
    }
    while (q--) {
      long long x;
      cin >> x;
      set<long long>::iterator it = s.begin();
      if (s.find(x) != s.end()) {
        if (*it == x) {
          s.erase(x);
          it = s.begin();
          cout << *it << '\n';
        } else if (abs(x - *it) % p == 0) {
          s.erase(abs(x - *it));
          it = s.begin();
          cout << *it << '\n';
        } else {
          it = s.begin();
          while (it != s.end() && abs(*it - x) % p != 0) {
            it++;
          }
          s.erase(*it);
          it = s.begin();
          cout << *it << '\n';
        }
      } else {
        it = s.begin();
        while (it != s.end() && abs(*it - x) % p != 0) {
          it++;
        }
        s.erase(*it);
        it = s.begin();
        cout << *it << '\n';
      }
    }
  }
  return 0;
}
