#include <bits/stdc++.h>
int dx[] = {0, 0, 1, -1, 2, 2, -2, -2, 1, -1, 1, -1};
int dy[] = {1, -1, 0, 0, 1, -1, 1, -1, 2, 2, -2, -2};
using namespace std;
class PAIR {
 public:
  long long int first;
  long long int second;
  long long int third;
};
vector<long long int> V, V2, V3;
long long int ar[4500100];
map<long long int, long long int> m;
int main() {
  long long int tcase = 1;
  for (long long int test = 1; test <= tcase; test++) {
    for (long long int i = 0; i <= 450010; i++) {
      ar[i] = i;
    }
    long long int q, x, ans = 0;
    scanf("%lld %lld", &q, &x);
    long long int a;
    for (long long int i = 0; i < q; i++) {
      scanf("%lld", &a);
      if (a == ans) {
        ans++;
        m[ar[a % x]] = 1;
        while (m.count(ans) == 1) {
          ans++;
        }
        ar[a % x] += x;
        printf("%lld\n", ans);
        continue;
      }
      a %= x;
      m[ar[a]] = 1;
      if (ans == ar[a]) {
        ans++;
        while (m.count(ans) == 1) {
          ans++;
        }
      }
      ar[a] += x;
      printf("%lld\n", ans);
    }
  }
}
