import java.util.*;

public class D {
    public static void main (String[]  args) {
        Scanner in = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        int q = in.nextInt();
        int k = in.nextInt();
        int a[] = new int[k];
        int mex = 0;
        int curr = 0;
        
        while(q-- > 0) {
            int num = in.nextInt();
            a[num%k]++;
            while(a[mex] > curr) {
                mex++;
                if(mex == k) {
                    mex = 0;
                    curr++;
                }
            }
            sb.append(curr*k + mex).append("\n");
        }
        System.out.println(sb);
    }
}