import java.util.*;

public class D_MEX_maximizing{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        int ans=0;
        int x=sc.nextInt();
        int ar[]=new int[x];
        StringBuilder sb=new StringBuilder();
        while (q-- > 0) {
            int n = sc.nextInt();
            int r=n%x;
            if(r==ans%x)
            {
                ans++;
                while(true)
                {
                    if(ar[ans%x]>0)
                    {
                        ar[ans%x]--;
                        ans++;
                    }
                    else
                    {
                        break;
                    }
                }
                sb.append(ans+"\n");
            }
            else
            {
                ar[r]++;
                sb.append(ans+"\n");
            }
            
        }
        System.out.println(sb);
    }
}