x, n = map(int, input().split()) A = list(map(int, input().split())) mod = 1000003 def power(a, n, mod): bi=str(format(n,"b")) res=1 for i in range(len(bi)): res=(res*res) %mod if bi[i]=="1": res=(res*a) %mod return res ans = 0 for a in A: ans += power(x, a, mod) print(ans%mod)