N,mod=map(int,input().split()) count=0 v=[0]*(N+1) A=list(map(int,input().split())) a=1 a%=mod for i in range(N-1): a*=2 a%=mod b=2*a b%=mod for i in range(N): x=A[i] if v[x]==0: v[x]=1 count+=1 else: v[x]=0 count-=1 if count==0: print(b) else: print(a)