n,b = map(int,input().split()) a = list(map(int,input().split())) s = set(); c = n for v in a: if v in s: c = -1 else: c -= 1; s.add(v) print((pow(2,n,b)-pow(2,c,b)*(c>=0))%b)