const MOD: usize = 1_000_003; fn mpow(x: usize, n: usize) -> usize { if n == 0 { 1 } else if n % 2 == 0 { mpow(x * x % MOD, n / 2) } else { mpow(x * x % MOD, n / 2) * x % MOD } } fn main() { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let mut s = s.trim().split_whitespace(); let x: usize = s.next().unwrap().parse().unwrap(); let mut a = String::new(); std::io::stdin().read_line(&mut a).ok(); let a: Vec = a.trim().split_whitespace() .map(|e| e.parse().unwrap()).collect(); let mut ans: usize = 0; for i in a { ans += mpow(x, i); } println!("{}", ans); }