x, N = map(int,input().split()) A = list(map(int,input().split())) mod = 1000003 ans = 0 for a in A: ans += (x**a)%mod print(ans)