let n = stdin.ReadLine() |> int let a = stdin.ReadLine().Split() |> Array.toList let canCalc n1 n2 op = if n1 = "+" || n1 = "-" then false elif n2 = "+" || n2 = "-" then false elif op <> "+" && op <> "-" then false else true let rec roop (xs: string list) ys = if xs.Length < 3 then let tmp = List.rev xs @ ys if tmp.Length = 1 then // 戻り値 tmp else roop (List.rev tmp) [] else let x1 :: x2 :: x3 :: rest = xs if canCalc x1 x2 x3 then if x3 = "+" then let y = int x1 + int x2 |> string roop rest (y :: ys) else let y = int x1 - int x2 |> string roop rest (y :: ys) else roop (List.tail xs) (x1 :: ys) roop a [] |> List.head |> printfn "%s"