
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class a {

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

		public pair(int q, int w) {
			x = q;
			y = w;
		}

		@Override
		public String toString() {
			return "(" + x + " " + y + ")";
		}

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

	public static class UnionFind {
		int[] p, rank, setSize;
		int numSets;
		Queue<Integer> subs[];

		public UnionFind(int N) {
			p = new int[numSets = N];
			rank = new int[N];
			setSize = new int[N];
			subs = new LinkedList[N];
			for (int i = 0; i < N; i++) {
				subs[i] = new LinkedList<Integer>();
				subs[i].add(i);
				p[i] = i;
				setSize[i] = 1;

			}
		}

		public int findSet(int i) {
			return p[i] == i ? i : (p[i] = findSet(p[i]));
		}

		public boolean isSameSet(int i, int j) {
			return findSet(i) == findSet(j);
		}

		public void unionSet(int i, int j) {
			if (isSameSet(i, j))
				return;
			numSets--;
			int x = findSet(i), y = findSet(j);
			if (rank[x] > rank[y]) {
				p[y] = x;
				while (!subs[y].isEmpty())
					subs[x].add(subs[y].poll());
				setSize[x] += setSize[y];
			} else {
				p[x] = y;
				setSize[y] += setSize[x];
				while (!subs[x].isEmpty())
					subs[y].add(subs[x].poll());
				if (rank[x] == rank[y])
					rank[y]++;
			}
		}

		public int numDisjointSets() {
			return numSets;
		}

		public int sizeOfSet(int i) {
			return setSize[findSet(i)];
		}
	}

	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;
			}
	}

	static boolean isPrime(int N) {
		if (N < isComposite.length)
			return isComposite[N] == 0;
		for (int p : primes) // may stop if p * p > N
			if (N % p == 0)
				return false;
		return true;
	}

	static int m;
	static ArrayList<pair> mask;

	// 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 {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		StringTokenizer st = new StringTokenizer(br.readLine());
		int q = Integer.parseInt(st.nextToken());
		int x = Integer.parseInt(st.nextToken());
		HashMap<Integer, Integer> hm = new HashMap<>();
		PriorityQueue<pair> pq = new PriorityQueue<>();
		for (int i = 1; i <= q; i++) {
			int y = Integer.parseInt(br.readLine()) % x;
			pair p = new pair(y, i);
			int ti = 0;
			if (hm.containsKey(y)) {
				ti = hm.get(y);
				hm.put(y, hm.get(y) + 1);
			} else {
				hm.put(y, 1);
			}
			pq.add(new pair(y + x * ti, i));
		}
		int si = pq.size();
		int max = -1;
		ArrayList<pair> sol = new ArrayList<>();
		int sum = 0;
		int o = 0;
		boolean f = true;
		for (int i = 0; i < si; i++) {
			pair p = pq.poll();
			int a = p.x;
			int s = p.y;
			if (s > max) {
				max = s;
				if (a == i) {
					sol.add(new pair(o, max - sum - 1));
					sum += max - sum - 1;
				}
			}
			if (a == i)
				o++;

			if (a != i) {
				sol.add(new pair(i, sol.size() == 0 ? q : q - sum));
				f=false;
				break;
			}
		}
		if (f)
			sol.add(new pair(o, q - sum));
		Collections.sort(sol);
		si = sol.size();
		for (int i = 0; i < si; i++) {
			pair p = sol.get(i);
			for (int j = 0; j < p.y; j++) {
				pw.println(p.x);
			}
		}
		pw.flush();
	}

}