import java.io.*;
import java.util.*;

public class Maximize_MEX
{
	
	static int mex;
	static Map<Integer,Integer> hm;
	static int max_mex;
	
	public static void main(String args[]) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(new BufferedInputStream(System.in)));
		
		String line[] = br.readLine().split(" ");
		
		int q = Integer.parseInt(line[0]);
		int x = Integer.parseInt(line[1]);
		
		hm = new HashMap<Integer,Integer>();
		
		mex = 0;
		max_mex = 0;
	
		while(q-->0)
		{
			int y = Integer.parseInt(br.readLine());
			
			// if(y == mex)
			// {
				// System.out.println(++mex);
			// }
			// else
			// {
				if(hm.containsKey(y%x))
				{
					hm.put(y%x,hm.get(y%x)+1);
				}
				else
				{
					hm.put(y%x,1);
				}
				
				while(hm.containsKey(mex % x))
				{
					if(hm.get(mex%x)!=0)
					{
						hm.replace(mex % x,hm.get(mex % x)-1);
						mex++;
						
						
						
					}
					else
						break;
				}
				
				System.out.println(mex);
				
			// }

		}
		
	}
}