import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Collection;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.util.StringTokenizer;
import java.util.Queue;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.LinkedList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DMEXMaximizing solver = new DMEXMaximizing();
        solver.solve(1, in, out);
        out.close();
    }

    static class DMEXMaximizing {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int n = sc.nextInt(), x = sc.nextInt();
            TreeSet<Integer> set = new TreeSet<>();
            Queue<Integer>[] mods = new LinkedList[x];
            for (int i = 0; i < x; i++)
                mods[i] = new LinkedList<>();
            for (int i = 0; i <= n; i++)
                set.add(i);
            for (int i = 0; i < x; i++)
                for (int j = i; j < n; j += x)
                    mods[i].add(j);
            for (int i = 0; i < n; i++) {
                int temp = sc.nextInt();
                int mod = temp % x;
                if (!mods[mod].isEmpty())
                    set.remove(mods[mod].poll());
                pw.println(set.first());
            }
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

