import sys
input = sys.stdin.readline



q,x = map(int,input().split())
Table = [0] * x
# THis is our table      
# Value                     0     1    2    3     4     5  ..    x - 1  
# How many encountered      0     0    0    0     0     0  ..      0   
 
 
hunting = 0
for i in range(q):
    val = int(input()) % x
 
    Table[val] += 1
 
    # max search x times (cyclic)
    if(val == hunting):  # Hoorayyy!!!!! We found what we are looking for
        # Update the hunting and print the hunter
        requirement = Table[val]
        for it in range(hunting+1, hunting + x - 1):
            if(it%x == 0):
                requirement += 1
            if(Table[it%x] != requirement):
                hunting = it%x
                break
        hehe = (hunting - 1) % x
        print((Table[hehe]-1) * x + hehe + 1)
        continue
    print(Table[hunting] * x + hunting)

