#include <bits/stdc++.h>
using namespace std;
template <typename T>
void make_unique(vector<T> &vec) {
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
}
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
template <typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
const long long inf = 1000000000000000;
bool ispalindrome(string s) {
  long long int len = s.length();
  for (long long int i = 0; i < len; i++) {
    if (s[i] != s[len - i - 1]) return false;
  }
  return true;
}
long long mbinpow(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = (res % 1000000007 * a % 1000000007) % 1000000007;
    a = (a % 1000000007 * a % 1000000007) % 1000000007;
    b >>= 1;
  }
  return res % 1000000007;
}
long long binpow(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a);
    a = (a * a);
    b >>= 1;
  }
  return res;
}
bool is_prime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
long long inv(long long a) { return mbinpow(a, 1000000007 - 2); }
long long C(long long int n, long long int r) {
  if (n < r) return 0;
  if (n == r) return 1;
  if (r > n - r) r = n - r;
  long long ans = 1;
  long long int i;
  for (i = 1; i <= r; i++) {
    ans *= n - r + i;
    ans /= i;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int q, k;
  cin >> q >> k;
  unordered_map<long long int, long long int> mp, pp;
  long long int mex = 0;
  while (q--) {
    long long int y;
    cin >> y;
    if (y == mex) {
      mp[y]++;
      mex++;
      cout << mex << '\n';
    } else {
      mp[y]++;
      long long int req = abs(y - mex) % k;
      if (req == 0) {
        mex++;
        req = (mex - k) % k;
        while (mp[req] > 1) {
          mex++;
          mp[req]--;
          req = (mex - k) % k;
        }
      }
      cout << mex << '\n';
    }
  }
  return 0;
}
