x,N = map(int, input().split()) A = list(map(int, input().split())) MOD = 10**6+3 ans = 0 for i in range(N): ans += pow(x, A[i], MOD) ans %= MOD print(ans)