#P6420. Kornislav's Largest Rectangle

    ID: 19635 Type: Default 1000ms 256MiB

Kornislav's Largest Rectangle

Kornislav's Largest Rectangle

Turtle Kornislav has lived for three centuries and has grown tired of the mundane. To pass the time one weekend, he invented a game he calls "The Largest Rectangle." Kornislav chooses four positive integers. He then takes a walk in the following way: he starts walking in one direction, then makes a \(90^\circ\) turn, continues walking, makes another \(90^\circ\) turn, walks again, makes a third \(90^\circ\) turn, and finally walks a fourth segment. Each of the four chosen integers is used exactly once as the length of one segment. Note that not all sequences of moves will form a closed shape, but some will enclose a rectangle.

Your task is to compute the maximum rectangle area that can be formed by arranging the four integers in an appropriate order. It can be shown that the optimal rectangle area is given by the product of the smallest and the third smallest integer when the four numbers are sorted in non-decreasing order. Mathematically, if the sorted numbers are \(a \leq b \leq c \leq d\), the maximum rectangle area is \(a \times c\).

inputFormat

The input consists of a single line with four positive integers separated by spaces.

outputFormat

Output the maximum rectangle area that Turtle Kornislav can obtain.

sample

1 2 3 4
3