module ModMath def ModMath.pow(base, power, mod) result = 1 while power > 0 result = (result * base) % mod if power & 1 == 1 base = (base * base) % mod power >>= 1; end result end end x, n = gets.split.map(&:to_i) a = gets.split.map(&:to_i) md = 1_000_003 sum = 0 n.times do |i| sum = (sum + ModMath.pow(x, a[i], md)) % md end puts sum