x, cnt = map(int,input().split()) ans = 0 a = list(int(i) for i in input().split()) for i in a: ans += pow(x,i,1000003) print(ans)