x,N = map(int,input().split()) a = list(map(int,input().split())) P = 10 ** 6 + 3 ans = 0 for i in a: ans = (ans + pow(x,i,P)) % P print(ans)