class Fixnum def power(x) result = 1 n = self while x > 0 result = (result * n) % 1_000_003 if (x & 1).nonzero? n = (n * n) % 1_000_003 x >>= 1 end result end end class Yukicoder EPS = 1_000_003 def initialize x, n = gets.chomp.split(' ').map(&:to_i) a = gets.chomp.split(' ').map(&:to_i) puts a.map{|i| x.power(i)}.inject(:+) % EPS end end Yukicoder.new