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