use std::io::*; use std::ops::*; use std::str::FromStr; use utils::*; pub fn main() { let i = stdin(); let mut o = Vec::new(); run(i.lock(), &mut o); stdout().write_all(&o).unwrap(); } fn run(i: R, o: &mut W) { let mut i = CpReader::new(i); let (x, n) = i.read2::(); let a = i.read_vec::(n); writeln!(o, "{}", solve(x, &a)).unwrap(); } fn solve(x: usize, a: &[usize]) -> usize { let x = ModInt::new(x); let mut r = ModInt::new(0); for &a in a { r += x.pow(a); } r.0 } mod utils { use super::*; pub struct CpReader { r: R, s: String, } macro_rules! fn_read { {$f:ident($($v:ident: $t:ident),*)} => { pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) { let i = &mut self.read_line().split(' '); $( let $v = i.next().unwrap().parse().ok().unwrap(); )* ($($v),*) } }; } impl CpReader { pub fn new(r: R) -> Self { CpReader { r: r, s: String::new(), } } pub fn read_line(&mut self) -> &str { self.s.clear(); self.r.read_line(&mut self.s).unwrap(); self.s.trim() } fn_read! { read2(v1: T1, v2: T2) } pub fn read_vec(&mut self, n: usize) -> Vec { self.read_line() .split(' ') .take(n) .map(|x| x.parse().ok().unwrap()) .collect() } } #[derive(Debug, Clone, Copy)] pub struct ModInt(pub usize); const MOD_BASE: usize = 1000003; impl ModInt { pub fn new(n: usize) -> Self { ModInt(n % MOD_BASE) } pub fn pow(self, mut exp: usize) -> Self { let mut b = self; let mut r = ModInt(1); while exp != 0 { if exp % 2 == 1 { r *= b; } exp /= 2; b = b * b; } r } } macro_rules! ModInt_op { (($ot:ident, $f:ident), ($ot_a:ident, $f_a:ident), $($rhs:ty, $e:expr,)*) => { $( impl $ot<$rhs> for ModInt { type Output = Self; fn $f(self, rhs: $rhs) -> Self { Self::new(($e)(self, rhs)) } } impl $ot_a<$rhs> for ModInt { fn $f_a(&mut self, rhs: $rhs) { *self = Self::new(($e)(*self, rhs)) } } )* } } ModInt_op!( (Add, add), (AddAssign, add_assign), ModInt, |l: ModInt, r: ModInt| l.0 + r.0, usize, |l: ModInt, r: usize| l.0 + r, ); ModInt_op!( (Mul, mul), (MulAssign, mul_assign), ModInt, |l: ModInt, r: ModInt| l.0 * r.0, usize, |l: ModInt, r: usize| l.0 * r, ); ModInt_op!( (Sub, sub), (SubAssign, sub_assign), ModInt, |l: ModInt, r: ModInt| MOD_BASE + l.0 - r.0, usize, |l: ModInt, r: usize| MOD_BASE + l.0 - r, ); }