let read() = stdin.ReadLine().Split() |> Array.map(int64) let (|Odd|Even|) n = if n%2L=1L then Odd else Even let modVal = 1000003L let rec modPow x = function | 0L -> 1L | Even as n -> modPow (x*x%modVal) (n/2L) | Odd as n -> (x*(modPow x (n-1L))) % modVal let x,N = let t = read() in t.[0],t.[1] let a = read() a |> Array.fold(fun acc a -> (acc + (modPow x a))%modVal) 0L |> printfn "%i"