func main() var n: int :: cui@inputInt() var a: []int :: #[n - 1]int for i(0, n - 2) do a[i] :: cui@inputInt() end for var num: int :: 0 var ans: int :: 0 for i(0, n - 2) var b: int :: cui@inputInt() var c: int :: cui@inputInt() do num :+ c - b do ans :+ num * a[i] end for do cui@print("\{ans}\n") end func