import java.io.*; 
import java.util.*; 
  
public class  MEX_maximizing 
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
    
    public static void main(String[] args) 
    { 
        FastReader sc=new FastReader(); 
        StringBuilder s=new StringBuilder();
        int uptodate=0;

        TreeMap<Integer,Integer> mp=new TreeMap<>();
        int map_size=0;
        int q=sc.nextInt(),k=sc.nextInt();
        for(int i=0;i<q;i++)
        {
            int x=sc.nextInt();

            if(x==uptodate)
            {
                uptodate++;
                if(mp.get(uptodate)!=null)
                {
                    mp.put(uptodate ,mp.get(uptodate)-1);
                    if(mp.get(uptodate)==0)
                        mp.remove(uptodate);
                    map_size--;
                    uptodate++;

                }
            }
            else
            {
                if(mp.get(x)==null)
                    mp.put(x,1);
                else
                    mp.put(x,mp.get(x)+1);
                map_size++;
            }

            //System.out.println(mp);

            if(uptodate==0)
                s.append(0+"\n");
            else
            {
                if(map_size==0)
                    s.append(uptodate+"\n");
                else
                {
                    int arr[]=new int[map_size];
                    boolean b[]=new boolean[map_size];

                    TreeMap<Integer,Integer> temp=new TreeMap<>(mp);
                    //temp=(TreeMap)mp.clone();
                    int index=0;
                    for(Map.Entry entry:temp.entrySet())
                    {
                        int z=(int)entry.getKey();
                        for(int j=0;j<(int)entry.getValue();j++)
                        {
                            arr[index++]=z;
                        }
                    }

                    //System.out.println("jdjdjdj");

                    int ans=uptodate;
                    boolean pre=true;
                    while(pre)
                    {
                        pre=false;
                        for(int j=0;j<map_size;j++)
                        {
                            if(b[j]==false&& (arr[j]-ans)%k==0)
                            {
                                b[j]=true;
                                pre=true;
                                ans++;
                                break;
                                

                            }
                        }
                    }

                    s.append(ans+"\n");

                }
            }

        }

        System.out.println(s);
        
    } 
}   