require 'pp' MOD = 1000003 def pow(x, a) if a === 0 return 1 end p = 1 while a > 0 do if a % 2 > 0 p = (p * x) % MOD end x = (x * x) % MOD a /= 2 end return p end x, n = gets.strip.split.map { |e| e.to_i } a = gets.strip.split.map { |e| e.to_i } # pp a.map { |e| pow(x, e)} total = a.reduce(0){|sum, p| (sum + pow(x, p)) % MOD} puts total