quernums,x=map(int,input().split( ))
mex=list(range(quernums))
for b in range(quernums):
    query=int(input())
    array0=[]
    array0.append(query)
    if query in mex:
        mex.remove(query)
    if b!=quernums-1:
        print(mex[0])
mex.reverse()
print("this is mex"+str(mex))
array0.sort()
cv=0
while cv<=len(array0)-2 and len(mex)!=0:
    if ((array0[cv]-mex[-1])%x==0 and array0[cv]>mex[-1]) and (array0[cv]==array0[cv+1] or array0[cv]>mex[-1]):
        array0[cv]=mex[-1]
        cv=0
        array0.sort()
        mex.pop(-1)
    else:
        cv+=1
if len(mex)==0:
    print(quernums)
else:
    print(mex[-1])
