from math import log10 x, N = map(int, input().split()) a = list(map(int, input().split())) xp = 0 n = 1000003 def keta(x, a): ketasuu = int(a * log10(x)) + 1 return ketasuu def amari(x, a, n): global xp if keta(x, a) <= 9: return (x ** a) % n else: result = 0 r = a // xp result = amari(j, r, n) * (x ** (a % xp) % n) % n return result if x > 1: i = 0 while(True): if x ** i > n: xp = i j = (x ** i) % n break i += 1 shiguma = 0 for i in range(N): shiguma += amari(x, a[i], n) shiguma = shiguma % n print(shiguma)