x,n = map(int,input().split()) A = list(map(int,input().split())) mod = 10**6+3 ans = 0 for i in range(n): ans += pow(x,A[i],mod) print(ans)