x, N = map(int, input().split()) A = list(map(int, input().split())) S = 0 mod = int(1e6) + 3 def doubling(n, m): y = 1 base = n tmp = m while tmp != 0: if tmp % 2 == 1: y *= base y %= mod base *= base base %= mod tmp //= 2 return y for i in A: S += doubling(x, i) S %= mod print(S)