N,mod=map(int,input().split()) count=0 v=[0]*(N+1) A=list(map(int,input().split())) a=1 u=[1]*(N+1) u[0]%=mod for i in range(1,N+1): u[i]=u[i-1]*2 u[i]%=mod R=set() ans=True for i in range(N): x=A[i] if x in R: ans=False R.add(x) if ans==True: result=u[N]-u[N-len(R)] result%=mod print(result) else: print(u[N])