d=1000003 x,n,*a=$<.read.split.map &:to_i s=0;a.map{|e|t=1;(e%d).times{t=(t*x)%d};s+=t};p s%d