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

public class CF1294D extends PrintWriter {
	CF1294D() { super(System.out); }
	static class Scanner {
		Scanner(InputStream in) { this.in = in; } InputStream in;
		int k, l; byte[] bb = new byte[1 << 15];
		byte getc() {
			if (k >= l) {
				k = 0;
				try { l = in.read(bb); } catch (IOException e) { l = 0; }
				if (l <= 0) return -1;
			}
			return bb[k++];
		}
		int nextInt() {
			byte c = 0; while (c <= 32) c = getc();
			int a = 0;
			while (c > 32) { a = a * 10 + c - '0'; c = getc(); }
			return a;
		}
	}
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF1294D o = new CF1294D(); o.main(); o.flush();
	}

	void main() {
		int q = sc.nextInt();
		int n = sc.nextInt();
		long[] aa = new long[n];
		for (int i = 0; i < n; i++)
			aa[i] = i;
		int[] ii = new int[q];
		for (int h = 0; h < q; h++) {
			int i = sc.nextInt() % n;
			ii[h] = i;
			aa[i] += n;
		}
		long a = aa[0];
		for (int i = 1; i < n; i++)
			a = Math.min(a, aa[i]);
		long[] mex = new long[q];
		for (int h = q - 1; h >= 0; h--) {
			mex[h] = a;
			int i = ii[h];
			a = Math.min(a, aa[i] -= n);
		}
		for (int h = 0; h < q; h++)
			println(mex[h]);
	}
}
