open System open System.Collections.Generic [] module Cin = let read f = stdin.ReadLine() |> f let reada f = stdin.ReadLine().Split() |> Array.map f let readInts() = read string |> Seq.toArray |> Array.map (fun x -> Convert.ToInt32(x.ToString())) module Util = let strRev s = s |> Seq.rev |> Seq.map string |> String.concat "" [] let main _ = let N = read int let P = reada int64 let mutable k = Array.fold (fun acc (x: int64) -> acc * Numerics.BigInteger(x)) 1I P while k > 9I do let mutable a = k let mutable dsum = 0I while a > 0I do dsum <- dsum + (a % 10I) a <- a / 10I k <- dsum printfn "%A" k 0 // return an integer exit code 0 // return an integer exit code