class modint: def __init__(self,mod): self.mod = mod def plus(self,x,y): n = x + y n %= self.mod return n def times(self,x,y): return (x*y)%self.mod def pow(self,n,m): """ n^m """ l = len(bin(m)) - 2 d = [n] for i in range(1,l): a = d[i-1]*d[i-1] a %= self.mod d.append(a) ans = 1 for i in range(l): if m >> i & 1: ans *= d[i] ans %= self.mod return ans def combination(self,n,r): """ nCrを計算。 """ a = 1 #n! b = 1 #(n-r)! c = 1 #r! for i in range(2,n+1): a *= i a %= self.mod if i == n-r: b = a if i == r: c = a b = self.inverse(b) c = self.inverse(c) a *= b a %= self.mod a *= c a %= self.mod return a def inverse(self,n): return self.pow(n,self.mod-2) def main(): import sys input = sys.stdin.readline x,N = map(int,input().split()) a = list(map(int,input().split())) mod = 10**6+3 mi = modint(mod) count = 0 for i in range(N): count += pow(x,a[i],mod) print(count) if __name__ == '__main__': main()