https://cses.fi/problemset/task/2191 Input Format Check Link Output Format Check Link Constraints Check Link Example Input 4 1 1 4 2 3 5 1 4 Output 16 Watch Explanation Video tutorial