def BinPower(x, k, mod = 10**9+7): ret = 1 while k > 0: if k & 1: ret = ret * x % mod x = x * x % mod k >>= 1 return ret mod = 1000003 x,N = map(int,input().split()) a = list(map(int,input().split())) ans = 0 for i in range(N): ans += BinPower(x, a[i], mod) ans %= mod print(ans)