https://cses.fi/problemset/task/2193 Input Format Check Link Output Format Check Link Constraints Check Link Example Input 4 1 1 5 3 3 5 1 4 Output 6 8 Watch Explanation Video tutorial