# your code goes here
x,N=(int(i) for i in input (). split ())
a=[int(i) for i in input (). split ()]
k=0
for i in range (N):
  #  print (
    k+=x**a[i]
    k%=1000003
#    print (k)
print (k)