#include <bits/stdc++.h>
using namespace std;
int n, k, book[400005];
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    q;
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < k; i++) q.push(make_pair(0, i));
  for (int i = 1, a; i <= n; i++) {
    scanf("%d", &a);
    book[a % k]++;
    q.push(make_pair(book[a % k], a % k));
    while (q.top().first != book[q.top().second]) q.pop();
    printf("%d\n", q.top().first * k + q.top().second);
  }
  return 0;
}
