import math class No16: x = 0 n = 0 num_list = [] def __init__(self): self.x, self.n = map(int, input().split(" ")) self.num_list = list(map(int, input().split(" "))) def solve(self): ans = 0 for y in self.num_list: ans += self.first_pow(self.x, y, 1000003) return ans def first_pow(self, x, y, m): if y == 0: return 1 elif y % 2 == 0: return self.first_pow(x * x % m, y // 2, m) else: return x * self.first_pow(x, y - 1, m) % m if __name__ == "__main__": que = No16() ans = que.solve() print(ans)