#include <bits/stdc++.h>
using namespace std;
long long int ar[400009];
long long int br[400009];
long long int a, b;
long long int test;
long long int sum, t, x = 0, p, q, y, i, j, k = 0, l = 0, cnt = 0, w = 0, h, z;
long long int s1;
int main() {
  long long int test;
  cin >> test >> b;
  while (test--) {
    long long int m = 1e+5;
    cnt = 0;
    cin >> a;
    ar[++k] = a % b;
    br[a % b]++;
    for (i = 0; i < b; i++) {
      m = min(m, br[i]);
    }
    for (i = 0; i < b; i++) {
      if (br[i] > m)
        cnt += 1;
      else
        break;
    }
    cout << m * b + cnt << endl;
  }
}
