
import java.io.*;
import java.util.*;

public class D {
    static StreamTokenizer in=null;
    public static void main(String[] args) throws IOException {
        in=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        int q=nextInt();
        int x=nextInt();

        //List<Integer> list=new LinkedList<>();
        //Map<Integer,Boolean> map=new HashMap<>();
        Set<Integer> set=new HashSet<>();
        int mex=0;
        int res[]=new int[400005];
        for(int i=0;i<q;i++){
            int n= nextInt();
            if(n>x){
                int temp= (int) Math.floor((n-mex)*1.0/x);
                n-=temp*x;
            }else if(n<x){
                int temp= (int) Math.floor((mex-n)*1.0/x);
                n+=temp*x;
                if(n<mex)n+=x;
            }
            if(n==mex) {
                while(res[mex]>0||n==mex){
                    if(res[mex]>0)
                      res[mex+x]+=res[mex]-1;
                    mex++;
                }
            }
            else res[n]++;
            out.println(mex);
            out.flush();
        }
    }

    static class InputReader{
        private BufferedReader in;
        private StringTokenizer tokenizer;
        public InputReader(InputStream stream){
            in = new BufferedReader(new InputStreamReader(stream),32768);
            InputReader reader = new InputReader(System.in);
            tokenizer = null;
        }
        public String next() throws IOException {
            while(tokenizer==null || !tokenizer.hasMoreTokens()){
                tokenizer = new StringTokenizer(in.readLine());
            }
            return tokenizer.nextToken();
        }
        public Long nextLong() throws IOException {
            String next = next();
            return Long.valueOf(next);
        }
        public int nextInt() throws IOException{
            return Integer.valueOf(next());
        }
    }
    public static double nextDouble() throws IOException{ in.nextToken(); return in.nval; }
    public static float nextFloat() throws IOException{ in.nextToken(); return (float)in.nval; }
    public static int nextInt() throws IOException{ in.nextToken(); return (int)in.nval; }
    public static String next() throws IOException{ in.nextToken(); return in.sval; }//仅能读取纯字母字符串有数字会返回null
}
