#include <bits/stdc++.h>
using namespace std;
long long int ar[500009], br[500009];
map<long long int, long long int> mp, cr;
int main() {
  long long int a, b, c, i, j = 0, k, x, y, z;
  cin >> a >> b;
  x = a;
  while (a--) {
    cin >> c;
    k = (c % b);
    mp[k + (cr[k] * b)]++;
    cr[k]++;
    while (1) {
      if (mp[j] == 0) {
        cout << j << endl;
        break;
      }
      j++;
    }
  }
}
