x,N = map(int,input().split()) sisuu_list = list(map(int,input().split())) sum = 0 for i in range(N): sum += pow(x,sisuu_list[i],1000003) print(sum % 1000003)