from __future__ import division, print_function
import bisect
import math
import itertools
import sys
from atexit import register
 
if sys.version_info[0] < 3:
    from io import BytesIO as stream
else:
    from io import StringIO as stream
 
 
if sys.version_info[0] < 3:
    class dict(dict):
        """dict() -> new empty dictionary"""
        def items(self):
            """D.items() -> a set-like object providing a view on D's items"""
            return dict.iteritems(self)
 
        def keys(self):
            """D.keys() -> a set-like object providing a view on D's keys"""
            return dict.iterkeys(self)
 
        def values(self):
            """D.values() -> an object providing a view on D's values"""
            return dict.itervalues(self)
 
    input = raw_input
    range = xrange
 
    filter = itertools.ifilter
    map = itertools.imap
    zip = itertools.izip
 
 
def sync_with_stdio(sync=True):
    """Set whether the standard Python streams are allowed to buffer their I/O.
 
    Args:
        sync (bool, optional): The new synchronization setting.
 
    """
    global input, flush
 
    if sync:
        flush = sys.stdout.flush
    else:
        sys.stdin = stream(sys.stdin.read())
        input = lambda: sys.stdin.readline().rstrip('\r\n')
 
        sys.stdout = stream()
        register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))
 
def main():
    a=[]
    zz=500050
    mex=[0]*zz
    b=[0]*zz
    ans=0
    n,k=map(int, input().split())
    for i in range (n):
        y=int(input())
        a.append(y%k)
    for i in range(n):
        if (k*b[a[i]])+a[i] >= len(mex):
            print(ans)
            continue
        if mex[(k*b[a[i]])+a[i]]==1:
            b[a[i]]+=1
            p=(k*(b[a[i]]))+a[i]
            if p>=len(mex):
                print(ans)
                continue
            mex[p]=1
        else:
            mex[(k*b[a[i]])+a[i]]=1
        while(mex[ans]==1 and ans<len(mex)):
            ans+=1
        print(ans)    
            


 

if __name__ == '__main__':
    sync_with_stdio(False)
    main()