x, a= [ int(v) for v in input().split() ] powlist = sorted([ int(v) for v in input().split() ]) mod = 1000003 def russian_cal(x,n): mullist = [] if n % 2 == 1: mullist.append(x) while n != 1: n //= 2 x = (x*x)%mod if n % 2 == 1: mullist.append(x) p = 1 for i in mullist: p = (p*i)%mod return p s = 0 for i in powlist: s += (russian_cal(x,i)%mod) print(s%mod)