x, n = [ int(v) for v in input().split(" ") ] nlist = [ int(v) for v in input().split(" ") ] maxn = max(nlist) bignum = 1000003 def powermod(x,n): powerlist = [1] * (n+1) for i in range(n): powerlist[i+1] = x * powerlist[i] powerlist[i+1] %= bignum return(powerlist) plist = powermod(x,maxn) anslist = [ plist[nlist[i]] for i in range(n) ] print(sum(anslist))