#include <bits/stdc++.h>
#pragma GCC optimize("O2", "unroll-loops")
using namespace std;
const int MAX = 4e5 + 5;
const long long MAX2 = 11;
const long long MOD = 1000000007;
const long long INF = 1e18;
const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1, 0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 2000;
int n, k, x, id, z[MAX];
bool vis[MAX];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= k; ++i) z[i] = i;
  while (n--) {
    cin >> x;
    x %= k;
    vis[min(z[x], MAX - 2)] = 1, z[x] = min(z[x] + k, MAX - 2);
    while (vis[id]) ++id;
    cout << id << "\n";
  }
  return 0;
}
