import java.util.*;
import java.io.*;
public class Main{
	
	 public static void main (String args[]){
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int l = sc.nextInt();
        int x = sc.nextInt();
        long arr1[] = new long[x], arr2[]=new long[l], arr3[]=new long[l], min=Long.MAX_VALUE, temp=0;
        
        for(int i=0; i<x; i++) {
        	arr1[i]=i;
        }
        	
        for(int i=0; i<l; i++) {
        	temp=sc.nextInt();
        	arr2[i]=temp%x;
        	arr1[(int)temp%x]+=x;
        }
        
        for(int i=0; i<x; i++) {
        	min = Math.min(min, arr1[i]);
        }
        
        for(int i=l-1; i>=0; i--) {
        	arr3[i]=min;
        	arr1[(int)arr2[i]%x]-=x;
        	min = Math.min(min, arr1[(int)arr2[i]%x]);
        }
        
        for(int i=0; i<l; i++)
        	out.println(arr3[i]);
        	
        out.flush();
        
    }
}
