x,N=map(int,input().split()) A=list(map(int,input().split())) m=100003 print(sum([pow(x,a,m) for a in A])%m)