open System let rec modPow(b: Int64, ex: Int64, mo: Int64) = if ex = 0 then 1L else let z = modPow(b, ex / 2L, mo) let zz = z * z % mo if ex % 2L = 0 then zz else b * zz [] 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