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

public class feb20 {

//__/\\\\\\\\\\\\\______/\\\\\\\\\_________/\\\\\\\\\___________/\\\\\\\\\__/\\\\\\\\\\\\\\\__/\\\\\\\\\\\________/\\\\\\\\\__/\\\\\\\\\\\\\\\_        
// _\/\\\/////////\\\__/\\\///////\\\_____/\\\\\\\\\\\\\______/\\\////////__\///////\\\/////__\/////\\\///______/\\\////////__\/\\\///////////__       
//  _\/\\\_______\/\\\_\/\\\_____\/\\\____/\\\/////////\\\___/\\\/_________________\/\\\___________\/\\\_______/\\\/___________\/\\\_____________      
//   _\/\\\\\\\\\\\\\/__\/\\\\\\\\\\\/____\/\\\_______\/\\\__/\\\___________________\/\\\___________\/\\\______/\\\_____________\/\\\\\\\\\\\_____     
//    _\/\\\/////////____\/\\\//////\\\____\/\\\\\\\\\\\\\\\_\/\\\___________________\/\\\___________\/\\\_____\/\\\_____________\/\\\///////______    
//     _\/\\\_____________\/\\\____\//\\\___\/\\\/////////\\\_\//\\\__________________\/\\\___________\/\\\_____\//\\\____________\/\\\_____________   
//      _\/\\\_____________\/\\\_____\//\\\__\/\\\_______\/\\\__\///\\\________________\/\\\___________\/\\\______\///\\\__________\/\\\_____________  
//       _\/\\\_____________\/\\\______\//\\\_\/\\\_______\/\\\____\////\\\\\\\\\_______\/\\\________/\\\\\\\\\\\____\////\\\\\\\\\_\/\\\\\\\\\\\\\\\_ 
//        _\///______________\///________\///__\///________\///________\/////////________\///________\///////////________\/////////__\///////////////__

	// created by : Nitesh Gupta

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String[] scn = (br.readLine()).trim().split(" ");
		int n = Integer.parseInt(scn[0]);
		int x = Integer.parseInt(scn[1]);
		int[] arr = new int[1000000];
		int mex = 0;

		for (int i = 0; i < n; i++) {
			scn = (br.readLine()).trim().split(" ");
			int ele = (int) Long.parseLong(scn[0]);
			if (ele == mex) {
			} else if (ele < mex) {
				int mul = (mex - ele + x - 1) / x;
				ele = ele + mul * x;
			} else {
				int mul = (ele - mex) / x;
				ele = ele - mul * x;
			}

			arr[ele] += 1;
			while (ele == mex) {
				mex = ele;
				if (arr[mex] > 1) {
					if (mex + x < 1000000)
						arr[mex + x] += arr[mex]-1;
				}
				mex += 1;
				if (arr[mex] > 0) {
					ele = mex;
				}
			}
			sb.append(mex + "\n");

		}
		System.out.println(sb);
		return;

	}

	public static void sec() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		StringBuilder sb = new StringBuilder();
		while (t-- > 0) {
			String[] scn = (br.readLine()).trim().split(" ");
			int n = Integer.parseInt(scn[0]);
			long[] arr = new long[n];
			scn = (br.readLine()).trim().split(" ");
			for (int i = 0; i < n; i++) {
				arr[i] = Long.parseLong(scn[i]);
			}
			sb.append("\n");
		}
		System.out.println(sb);
		return;

	}

	private static void third() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String[] scn = (br.readLine()).trim().split(" ");
		int n = Integer.parseInt(scn[0]);
		long[] arr = new long[n];
		scn = (br.readLine()).trim().split(" ");
		for (int i = 0; i < n; i++) {
			arr[i] = Long.parseLong(scn[i]);
		}
		System.out.println(sb);
		return;

	}

	public static void sort(long[] arr) {
		int n = arr.length;
		for (int i = 0; i < n; i++) {
			int idx = (int) Math.random() * n;
			long temp = arr[i];
			arr[i] = arr[idx];
			arr[idx] = temp;
		}

		Arrays.sort(arr);
	}

	public static void sort(int[] arr) {
		int n = arr.length;
		for (int i = 0; i < n; i++) {
			int idx = (int) Math.random() * n;
			int temp = arr[i];
			arr[i] = arr[idx];
			arr[idx] = temp;
		}
		Arrays.sort(arr);
	}

	public static void print(long[][] dp) {
		for (long[] a : dp) {
			for (long ele : a) {
				System.out.print(ele + " ");
			}
			System.out.println();
		}
	}

	public static void print(int[][] dp) {
		for (int[] a : dp) {
			for (int ele : a) {
				System.out.print(ele + " ");
			}
			System.out.println();
		}
	}

	public static void print(int[] dp) {
		for (int i = 0; i < 11; i++) {
			System.out.print(dp[i] + " ");
		}
		System.out.println();
	}

	public static void print(long[] dp) {
		for (long ele : dp) {
			System.out.print(ele + " ");
		}
		System.out.println();
	}

}