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