//SHIVAM GARG
import java.util.*;
import java.lang.*;
import java.io.*;
/*
7 3
0
1
2
2
0
0
10
*/
public class Codechef
{
 
 
	public static void main (String[] args) throws java.lang.Exception {
	    FastReader reader = new FastReader();
	    int q = reader.nextInt();
	    int w = reader.nextInt(), temp;
	    int[] tracker = new int[w];
	    int target =0, targetTemp;
	    for(int qq=0;qq<q;qq++){
	        temp = reader.nextInt() % w;
	        //System.out.println("Temp ==> " +  temp);
	        tracker[temp] = tracker[temp] +1;
	        //System.out.println("tracker, temp ==> " +  tracker[temp]);
	        while(true){
	            targetTemp = target %w;
	            if(tracker[targetTemp] ==0 ){
	                break;
	            }
	            tracker[targetTemp] = tracker[targetTemp]-1;
	            target++;
	        }
	        System.out.println(target);
	        
	    }
    }

	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        {  br = new BufferedReader(new InputStreamReader(System.in));  } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) { 
                try{    st = new StringTokenizer(br.readLine()); 
                }catch (IOException  e) { 
                    //e.printStackTrace();
                }
            } 
            return st.nextToken(); 
        }
  
        int nextInt() 
        { return Integer.parseInt(next());  } 
  
        long nextLong() 
        {  return Long.parseLong(next());  } 
  
        double nextDouble() 
        {  return Double.parseDouble(next());  } 
  
        String nextLine() { 
            String str = ""; 
            try{    str = br.readLine(); 
            } catch (IOException e) { 
                //e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
	
	
}