import java.util.*;
import static java.lang.Math.*;

import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;

public class A {
	static PrintWriter pw;
	static StringBuilder sb;
	static int inf = (int) 1e9;
	static long mod = (long) 1e9 + 7;
	static int[][] memo;
	static ArrayList<Integer> primes;
	static ArrayList<Integer>[] arr;
	static int n, k, m;
	static boolean[] vis;
	static boolean[] v;
	static HashSet<Integer> hs;
	static HashMap<Integer, Integer> hm;
	static HashSet<Integer> pr;
	static int[] ans, h1, h2;
	static int[] si;
	static int[] in;
	static HashMap<Integer, Integer> factors;
	static int[] fac, b;
	static int[] l, r;
	static int[] numc;
	static pair[] ed;
	static ArrayList<Integer>[] np;
	static TreeMap<pair, Integer> tm;
	static char[] h;
	static pair[] mm;
	static char[][] a;
	static char[] as = "IEHOVA#".toCharArray();

//	static ArrayList<Integer> primes;
	static int[] isComposite;

	static void sieve(int N) // O(N log log N)
	{
		isComposite = new int[N + 1];
		isComposite[0] = isComposite[1] = 1; // 0 indicates a prime number
		primes = new ArrayList<Integer>();

		for (int i = 2; i <= N; ++i) // can loop till i*i <= N if primes array is not needed O(N log log sqrt(N))
			if (isComposite[i] == 0) // can loop in 2 and odd integers for slightly better performance
			{
				primes.add(i);
				if (1l * i * i <= N)
					for (int j = i * i; j <= N; j += i) // j = i * 2 will not affect performance too much, may alter in
														// modified sieve
						isComposite[j] = 1;
			}
	}
// generated by sieve

	/*
	 * 1. Generating a list of prime factors of N
	 */
	static ArrayList<Integer> primeFactors(int N) // O(sqrt(N) / ln sqrt(N))
	{
		ArrayList<Integer> factors = new ArrayList<Integer>(); // take abs(N) in case of -ve integers
		int idx = 0, p = primes.get(idx);

		while (p * p <= N) {
			while (N % p == 0) {
				factors.add(p);
				N /= p;
			}
			p = primes.get(++idx);
		}

		if (N != 1) // last prime factor may be > sqrt(N)
			factors.add(N); // for integers whose largest prime factor has a power of 1
		return factors;
	}

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(System.out);
//		int t = Integer.parseInt(br.readLine());
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		int x = Integer.parseInt(st.nextToken());
		int l = 0;
		int w = 0;
		int[] a = new int[1000000];
		for (int i = 0; i < n; i++) {
			int t = Integer.parseInt(br.readLine());
			if (t == l) {
				a[t]++;
				pw.println(l + 1);
				l++;
			} else {
				int idx = t % x;
				a[(l - idx) / x * x + idx]++;

				while (true) {
					if (a[l] > 0) {

					} else if (l - x >= 0 && a[l - x] > 1) {
						a[l - x]--;
						a[l]++;
					} else if (l + x >= 0 && a[l + x] > 0) {
						a[l + x]--;
						a[l]++;
					} else
						break;
					l++;
				}
				for (; w <= l - x; w++) {
					a[(l - w) / x * x + w] += a[w] - 1;
					a[w] = 1;
				}
				pw.println(l);
			}
//			System.out.println(Arrays.toString(a));
		}

		pw.flush();
		pw.close();

	}

	static boolean check(int mid, int[] a2, int[] b2, int k2) {
		int i = a2.length - mid;
		int c = 0;
		long sum = 0;
		for (int j = 0; j < mid; j++) {
			if (j < m && a2[i] + k2 >= b2[j]) {
				if (a2[i] < b2[j])
					k2 -= (b2[j] - a2[i]);
				c++;
				i++;
			} else
				return false;
		}
		return true;
	}

	static String s;
	static int[] dx = new int[] { -1, 0, 1, 0 };
	static int[] dy = new int[] { 0, 1, 0, -1 };

	static boolean valid(int x, int y) {
		return x >= 0 && x < n && y >= 0 && y < m;
	}

	static void dfs(int x, int y, int c, String d) {
		if (c == 7) {
			s = d;
			return;
		}
		for (int i = 0; i < dx.length; i++) {
			int u = x + dx[i];
			int v = y + dy[i];
			if (valid(u, v) && a[u][v] == as[c]) {

				String temp = d;
				if (i == 1)
					temp += "0";
				else if (i == 3)
					temp += "1";
				else
					temp += "2";
//				System.out.println(temp);
				dfs(u, v, c + 1, temp);
			}
		}

	}

	static long dp(int idx, int a) {
		if (idx == m)
			return 1;
		if (memo[idx][a] != -1)
			return memo[idx][a];
		long ans = 0;
		for (int i = 0; i <= a; i++) {
			ans = ((i + 1) * 1l * dp(idx + 1, a - i) + ans) % mod;
		}

		return memo[idx][a] = (int) ((ans) % mod);
	}

	static boolean check(String s, int h, int m) {
		String s2 = reversString(m + "") + ":" + reversString(h + "");
		return s2.equals(com(h, m));

	}

	static String com(int h, int m) {
		String s = "";
		if (h < 10)
			s += "0" + h;
		else {
			s += h;
		}
		s += ":";
		if (m < 10)
			s += "0" + m;
		else {
			s += m;
		}
		return s;
	}

	static String reversString(String x) {
		int y = Integer.parseInt(x);
		if (y < 10)
			return x + "0";
		else
			return x.charAt(1) + "" + x.charAt(0);
	}

	static ArrayList<Integer>[] g;

	static class triple implements Comparable<triple> {
		int x;
		int y;
		int z;
		int w;

		public triple(int a, int b, int c, int d) {
			x = a;
			y = b;
			z = c;
			w = d;
		}

		@Override
		public int compareTo(triple o) {
			// TODO Auto-generated method stub
			return y - o.y;
		}
	}

	static long pow(long a, long e) // O(log e)
	{
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				res *= a;
			a *= a;
			e >>= 1;
		}
		return res;
	}

	static long gcd(long a, long b) {
		if (b == 0)
			return a;
		return gcd(b, a % b);
	}

	static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int d, int l) {
			x = d;
			y = l;
		}

		@Override
		public int compareTo(pair arg0) {
			// TODO Auto-generated method stub
			if (x == arg0.x) {
				return (int) (y - arg0.y);
			}
			return x - arg0.x;
		}
	}

}
