#include <bits/stdc++.h> 

using namespace std;

int main(){
	int q , x , v;
	cin >> q >> x;
	int arr[x] = {0};
	int index = 0;
	while(q--){
		cin >> v;
		int r = v%x;
		int val = arr[r];
		arr[r] = val+1;
		if (index==r){
			for (int i = 0 ; i< x ; i++){
				if (arr[i] < arr[index]) {
					index = i;
				}
			}
		}
		cout << arr[index]*x + index <<endl;
	}
	
	return 0;
}