n,p=map(int,input().split()) a=list(map(int,input().split())) a.sort() c=[{} for i in range(40)] L=10**10 g=0 for v in a: for i in range(1,40): if p**i