Under construction

Still being built. Things may change

Pairs

Interview

Time limit1sMemory limit1024 MB

Summary
Split four given integers into two pairs and print the largest possible sum of the two pair products.
Level

Easy3 of 10

Topics
Brute force, Math
Solved
No attempts yet

Problem

Four numbers aa, bb, cc, and dd are given. Split them into two pairs so that the sum of the products within the pairs is maximal.

For example, if the numbers are 2, 3, 4, and 5, the best split is (2,3)(2, 3) and (4,5)(4, 5). The sum is 2×3+4×5=262 \times 3 + 4 \times 5 = 26.

Input

Four numbers aa, bb, cc, and dd are given. The absolute value of each number does not exceed 1000.

Output

Print the maximum sum.

Examples1

  1. Example 1

    Input
    2 3 4 5
    
    Expected output
    26