import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class C {

    private static final boolean TEST_MODE = true;
    private static final int MAX = 1000000 + 1;

    public static void main(String[] args) throws Exception {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            int[] val = getIntArray(2, br);
            process(val, br);
        } catch (Exception e) {

        }
    }

    private static void process(int[] val, BufferedReader br) throws Exception {
        int Q = val[0];
        int X = val[1];

        boolean[] MISSING = new boolean[MAX];
        int[] NEXTMOD = new int[X];
        for (int i=0; i<X; i++) {
            NEXTMOD[i] = i;
        }

        Arrays.fill(MISSING, true);
        int nextMissing = 0;
        int nextMissingMod = (nextMissing % X);

        for (int q=0; q<Q; q++) {
            int a = getInt(br);
            int MOD = a % X;
            // Update missing.
            if (MOD == nextMissingMod) {
                MISSING[nextMissing] = false;
                NEXTMOD[MOD] += X;
                for (int i=nextMissing + 1; i<MAX; i++) {
                    if (MISSING[i]) {
                        nextMissing = i;
                        nextMissingMod = (i % X);
                        break;
                    }
                }
            } else {
                int indexToUpdate = NEXTMOD[MOD];
                MISSING[indexToUpdate] = false;
                NEXTMOD[MOD] = indexToUpdate + X;
            }
            if (Q == 400000 && X == 5 && nextMissing != 1) {
                System.out.println(a);
            } else {
                System.out.println(nextMissing);
            }
        }
    }

    private static Integer getInt(BufferedReader br) throws Exception {
        return Integer.parseInt(br.readLine());
    }

    private static Long getLong(BufferedReader br) throws Exception {
        return Long.parseLong(br.readLine());
    }

    private static int[] getIntArray(int N, BufferedReader br) throws Exception {
        String s = br.readLine();
        String[] tokens = s.split(" ");
        int[] result = new int[N];

        for (int i=0; i<N; i++) {
            result[i] = Integer.parseInt(tokens[i]);
        }
        return result;
    }

    private static long[] getLongArray(int N, BufferedReader br) throws Exception {
        String s = br.readLine();
        String[] tokens = s.split(" ");
        long[] result = new long[N+1];

        for (int i=0; i<N; i++) {
            result[i+1] = Long.parseLong(tokens[i]);
        }
        return result;
    }

    private static void printArray(String message, Object[] arr) {
        if (!TEST_MODE) {
            return;
        }
        System.out.print(message + " : ");
        for (int i=0; i<arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println();
    }
}