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