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

public class p1294D {

	public class Pair implements Comparable<Pair> {
		public int mod;
		public int cnt;

		public Pair(int mod) {
			this.mod = mod;
			this.cnt = 0;
		}

		public int compareTo(Pair p) {

			if(this.mod == p.mod) {
				//System.err.println("mods equal");
				return 0;
			}

			if(this.cnt < p.cnt) {
				return -1;
			} else if(this.cnt == p.cnt) {
				if(this.mod < p.mod) {
					return -1;
				} else if(this.mod == p.mod) {
					return 0;
				} else {
					return 1;
				}
			}

			return 1;
		}

		public boolean equals(Object o) {
			Pair p = (Pair)o;

			//System.err.println("calling equals: " + p.mod + ", " + this.mod);

			if(p.mod == this.mod) { //&& p.cnt == this.cnt) {
				return true;
			}

			return false;
		}

		public String toString() {
			return mod + ": " + cnt;
		}
	}

	public void realMain() throws Exception {

		BufferedReader fin = new BufferedReader(new InputStreamReader(System.in), 1000000);

		String in = fin.readLine();

		String[] ar = in.split(" ");

		int q = Integer.parseInt(ar[0]);
		int x = Integer.parseInt(ar[1]);
		
		//int[] cnt = new int[x];
		//int pointer = 0;

		//PriorityQueue<Pair> pq = new PriorityQueue<Pair>();
		TreeSet<Pair> pq = new TreeSet<Pair>();

		ArrayList<Pair> al = new ArrayList<Pair>();

		for(int i = 0; i < x; i++) {
			Pair p = new Pair(i);

			al.add(p);
			pq.add(p);
		}


		StringBuilder sb = new StringBuilder("");

		for(int i = 0; i < q; i++) {
			int ret = 0;
			boolean dig = false;
			for (int ch = 0; (ch = fin.read()) != -1; ) {
        			if (ch >= '0' && ch <= '9') {
            				dig = true;
           				ret = ret * 10 + ch - '0';
        			} else if (dig) break;
    			}

			/*cnt[ret % x]++;

			boolean keepgoing = true;

			while(keepgoing) {
				keepgoing = false;
				int nextpointer = (pointer+1) % x;

				if(cnt[pointer] > cnt[nextpointer]) {
					pointer = nextpointer;
					keepgoing = true;
				} else if(cnt[pointer] == cnt[nextpointer] && nextpointer == 0) {
					pointer = nextpointer;
					keepgoing = true;
				}
			}

			//System.err.println("added " + i + ": " + (ret % x) + "  ==> " + pointer);
*/

			

			/*boolean keepgoing = true;

			Pair top = pq.peek();

			while(keepgoing) {
				keepgoing = false;

				Pair tmp = pq.poll();
			//pq.remove(al.get(ret % x));
			//pq.add(al.get(ret % x));

				pq.add(tmp);

				top = pq.peek();

				if(!tmp.equals(top)) {
					keepgoing = true;
				}
			}*/

			//System.err.println();

			pq.remove(al.get(ret % x));

			al.get(ret % x).cnt++;

			pq.add(al.get(ret % x));

			
			Pair top = pq.first();

			//System.err.println("added " + i + ": " + (ret % x) + "  ==> " + top.mod);
			//System.err.println(pq);

			sb.append(top.cnt * x + top.mod);
			sb.append('\n');
			
		}

		System.out.println(sb);



	}


	public static void main(String[] args) throws Exception {
		p1294D a = new p1294D();
		a.realMain();
	}
}