a,b=map(int,input().split()) A=list(map(int,input().split())) ans=0 for x in A: ans+=(pow(a,x))%1000003 print(ans)