macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { #[allow(unused_mut)] let mut s = { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); s }; let mut iter = s.split_whitespace(); input_inner!{iter, $($r)*} }; } macro_rules! input_inner { ($iter:expr) => {}; ($iter:expr, ) => {}; ($iter:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($iter, $t); input_inner!{$iter $($r)*} }; } macro_rules! read_value { ($iter:expr, ( $($t:tt),* )) => { ( $(read_value!($iter, $t)),* ) }; ($iter:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($iter, $t)).collect::>() }; ($iter:expr, chars) => { read_value!($iter, String).chars().collect::>() }; ($iter:expr, usize1) => { read_value!($iter, usize) - 1 }; ($iter:expr, $t:ty) => { $iter.next().unwrap().parse::<$t>().expect("Parse error") }; } #[allow(dead_code)] type Pi = (i32, i32); fn pri(x: T) {println!("{}", x);} // Modint const MOD: u32 = 1_000_003; #[derive(Clone, Copy)] struct Mint(u32); impl std::ops::Add for Mint { type Output = Mint; fn add(self, x: Mint) -> Mint { let res = self.0 + x.0; Mint(if res >= MOD {res-MOD} else {res}) } } impl std::ops::AddAssign for Mint { fn add_assign(&mut self, x: Mint) { *self = *self + x; } } impl std::ops::Sub for Mint { type Output = Mint; fn sub(self, x: Mint) -> Mint { let res = self.0 + MOD - x.0; Mint(if res >= MOD {res-MOD} else {res}) } } impl std::ops::SubAssign for Mint { fn sub_assign(&mut self, x: Mint) { *self = *self - x; } } impl std::ops::Mul for Mint { type Output = Mint; fn mul(self, x: Mint) -> Mint {Mint((self.0 as u64 * x.0 as u64 % MOD as u64) as u32)} } impl std::ops::MulAssign for Mint { fn mul_assign(&mut self, x: Mint) { *self = *self * x; } } impl std::ops::Div for Mint { type Output = Mint; fn div(self, x: Mint) -> Mint { let mut a = x.0 as i64; //solves au + mv = 1 and u = a^-1 let mut m = MOD as i64; let mut u = 1i64; let mut v = 0i64; let mut buf: i64; while m != 0 { let t = a / m; a -= t * m; buf = a; a = m; m = buf; u -= t * v; buf = u; u = v; v = buf; } u %= m; if u < 0 {u += m;} self * Mint(u as u32) } } impl std::ops::DivAssign for Mint { fn div_assign(&mut self, x: Mint) { *self = *self / x; } } impl std::fmt::Display for Mint { fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result { write!(f, "{}", self.0) } } #[allow(dead_code)] impl Mint { pub fn pow(self, mut n: u32) -> Mint { let mut res = Mint(1); let mut r = self; while n > 0 { if n & 1 == 1 {res *= r;} r *= r; n >>= 1; } res } pub fn inv(self) -> Mint { assert!(self.0 > 0); self.pow(MOD - 2) } } fn main() { input!{ x: u32, n: usize, a: [u32; n], } let x = Mint(x); let mut ans = Mint(0); for e in a { ans += x.pow(e); } pri(ans); }