
def getMinExcluded(array):
    copy = []
    for i in range(len(array)):
        copy.append(array[i])
    copy.sort()
    m = 0
    for i in range(len(copy)):
        if m < copy[i]:
            break
        elif m == copy[i]:
            m += 1
    return m

def getDuplicates(current):
    copy = []
    for i in range(len(current)):
        copy.append([current[i], i])
    copy.sort()
    duplicates = []
    i = 1
    while i < len(copy):
        if copy[i - 1][0] == copy[i][0]:
            duplicates.append(copy[i])
        i += 1
    return duplicates

def minEx(current,toAdd,x):
    current
    cMin = getMinExcluded(current)
    if toAdd > cMin:
        if (toAdd-cMin)%x == 0:
            current.append(cMin)
            cMin = getMinExcluded(current)
        else:
            current.append(toAdd)
    else:
        if (cMin-toAdd)%x == 0:
            current.append(cMin)
            cMin = getMinExcluded(current)
        else:
            current.append(toAdd)
    return recMin(current,cMin,x)


def recMin(current,cMin,x):
    changed = False
    duplicates = getDuplicates(current)
    unusedlen = 0
    while not changed:
        unused = []
        for elem in duplicates:
            if elem[0] > cMin:
                if (elem[0] - cMin) % x == 0:
                    current[elem[1]] = cMin
                    cMin = getMinExcluded(current)
                    changed = True
                else:
                    unused.append(elem)
            else:
                if (cMin - elem[0]) % x == 0:
                    current[elem[1]] = cMin
                    cMin = getMinExcluded(current)
                    changed = True
                else:
                    unused.append(elem)
        if unusedlen == len(unused):
            break
        else:
            unusedlen = len(unused)
            duplicates = unused
    return current

#print(getMinExcluded(minEx([0,1,2,2,3,0],10,3)))
#
# test1X = 3
# test1 = [0,1,2,2,0,0,10]
# c1 = []
#
# for elem in test1:
#     c1 = minEx(c1,elem,test1X)
#     print(getMinExcluded(c1))
#
# test2X = 3
# test2 = [1,2,1,2]
# c2 = []
#
# for elem in test2:
#     c2 = minEx(c2,elem,test2X)
#     print(getMinExcluded(c2))

v1 = input()
v1 = v1.split(" ")
x = int(v1[1])
current = []
while True:
    try:
        val = int(input())
        current = minEx(current,val,x)
        print(getMinExcluded(current))
    except EOFError:
        break