let n = stdin.ReadLine () |> int let a = stdin.ReadLine().Split " " |> Array.map int if a.Length > 2 then [| for i in 0..a.Length-2 -> min a.[i] a.[i+1] |> int64 |] |> Array.reduce (fun prev x -> prev * x % 998244353L) else (Array.min a |> int64) % 998244353L |> printfn "%d" // let mutable arr = Array.replicate n [||] // arr.[0] <- Array.replicate a.[0] 1L // for i in 1..n-1 do // arr.[i] <- Array.replicate a.[i] ((Array.sum arr.[i-1].[0..a.[i]-1]) % 998244353L) // // printfn "%A" arr // // Array.last arr |> Array.head |> printfn "%d"