from sys import stdin
q,x=map(int,stdin.readline().split())
mx = 4*10**5+1
t_reszt = [0]*mx
t_wyn = [0]*mx
t_out = []
curr_ind = 0
out_curr_ind = 0
for y in range(q):
    curr_val = int(input())
    m = curr_val%x
    t_wyn[t_reszt[m]*x+m] = 1
    t_reszt[m] += 1
    curr_ind = out_curr_ind
    for z in range(curr_ind, len(t_wyn)-1):
        if t_wyn[z] == 0:
            t_out.append(z)
            out_curr_ind = z
            break
print("\n".join(map(str,t_out)))