const DIVISOR: u64 = 1_000_003; fn main() { let mut input = String::new(); std::io::Read::read_to_string(&mut std::io::stdin(), &mut input).ok(); let input: Vec = input .split_whitespace() .map(|n| n.parse().unwrap()) .collect(); let x = input[0]; let mut answer = 0; for &a in &input[2..] { let mut a = a; let mut pow = x; let mut product = 1; while a > 0 { if a & 1 == 1 { product *= pow; product %= DIVISOR; } pow *= pow; pow %= DIVISOR; a >>= 1; } answer += product; answer %= DIVISOR; } println!("{}", answer); }