/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
*/
import java.util.*;
import java.io.*;

   public class x1294D
   {
      public static void main(String omkar[]) throws Exception
      {
         //BufferedReader infile = new BufferedReader(new FileReader("cowdate.in"));
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int Q = Integer.parseInt(st.nextToken());
         int X = Integer.parseInt(st.nextToken());
         StringBuilder sb = new StringBuilder();
         TreeSet<Integer>[] bucket = new TreeSet[Q+1];
         for(int i=0; i <= Q; i++)
            bucket[i] = new TreeSet<Integer>();
         for(int i=0; i < X; i++)
            bucket[0].add(i);
         int[] curr = new int[X];
         boolean[] flag = new boolean[Q+1];
         int dex = 0;
         for(int i=0; i < Q; i++)
         {
            int val = Integer.parseInt(infile.readLine())%X;
            int prev = curr[val];
            bucket[prev].remove(val);
            bucket[prev+1].add(val);
            curr[val]++;
            if(bucket[prev].size() == 0 && (prev == 0 || flag[prev-1]))
            {
               flag[prev] = true;
               dex++;
            }
            int rem = bucket[dex].first();
            int res = dex*X+rem;
            sb.append(res+"\n");
         }
         System.out.print(sb);
      }
   }