Under construction

Still being built. Things may change

Turtle

Time limit1sMemory limit128 MB

Summary
Given four positive integers as segment lengths for a path with three right-angle turns, find the maximum rectangle area that can be enclosed (requires opposite sides equal).
Level

Easy3 of 10

Topics
Brute force, Math, Implementation
Solved
No attempts yet

Problem

A turtle has lived for 300 years and has tried almost everything, so it is looking for a way to pass the time. This weekend it will play a famous turtle-world game called "Make the Largest Rectangle".

Before the game starts, the turtle chooses four positive integers. It starts moving in one direction, then turns 90 degrees and moves in a new direction. It repeats this until it has turned three times and drawn four line segments.

Each segment length must be one of the four chosen integers, and each integer must be used exactly once. Different orders can create different shapes, and some shapes do not enclose any rectangle.

Given the four integers, compute the largest rectangle area the turtle can enclose.

Input

The first line contains four positive integers A, B, C, and D, the numbers chosen by the turtle. Each integer satisfies 0 < A, B, C, D < 100.

Output

Print the area of the largest rectangle the turtle can enclose.

Examples2

  1. Example 1

    Input
    1 2 3 4
    
    Expected output
    3
    
  2. Example 2

    Input
    4 4 3 4
    
    Expected output
    12