import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class D {
    static Map<Integer,Integer> map;
    public static void main(String[] args) throws IOException {
        BufferedReader inp = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));

        String[] s1 = inp.readLine().split(" ");
        int q = Integer.parseInt(s1[0]);
        int x = Integer.parseInt(s1[1]);

        map = new HashMap<>();
        ArrayList<Integer> list = new ArrayList<>();
        int max = 0;

        for(int t=0;t<q;t++){
            int a = Integer.parseInt(inp.readLine());
            a = a%x;
            if(map.containsKey(a)){
                map.put(a,map.get(a)+1);
            }
            else{
                map.put(a,1);
            }

            while (true){
                int d = check(max,x,a);
                if(d==max){
                    break;
                }
                else{
                    max = d;
                }
                list.add(max);
            }

            //System.out.println(map);
            out.write(max+"\n");




        }
        out.flush();


    }
    static int check(int max,int x,int a){
        int check = max;
        if(map.containsKey(max)){
            max++;
            return max;
        }
        //System.out.println(map);
        if(map.containsKey(check%x)){
            if(map.get(check%x)>1){
                map.put(check%x,map.get(check%x)-1);
                map.put(max,1);
                max++;

            }
        }
        return max;
    }

}
