open System let rec modPow(b: Int64, ex: Int64, mo: Int64) = if ex = 0 then 1L elif ex % 2L = 0 then let half = modPow(b, (ex / 2L), mo) (half * half) % mo else (b * modPow(b, (ex - 1L), mo)) % mo [] let yuki16 args : int = let [| x ; N |] = () |> stdin.ReadLine |> (fun it -> it.Split ' ') |> Array.map Int64.Parse () |> stdin.ReadLine |> (fun it -> it.Split ' ') |> Array.map Int64.Parse |> Array.map (fun l -> modPow(x, l, 1000003L)) |> Array.sum |> stdout.WriteLine 0