P1284 Triangular Pasture

Description

Like everyone, cows enjoy variety. They are imagining a new look for their pastures. The cow architect Hei wants to build a triangular pasture enclosed by a beautiful white fence. She has $n$ boards, each with an integer length $l_i$, and she wants to use all the boards to enclose a triangle so that the pasture area is maximized. Please help Miss Hei construct such a pasture and compute this maximum area.

Input Format

Line $1$: an integer $n$. Lines $2$ to $(n + 1)$: each line contains one integer. On line $(i + 1)$, the integer $l_i$ denotes the length of the $i$-th board.

Output Format

A single integer: the result of multiplying the maximum pasture area by $100$ and then truncating the fractional part. If it is impossible to construct, output $-1$.

Explanation/Hint

Explanation for Sample Input/Output 1: $692=\text{truncated}(100\times\text{triangle area})$, and the triangle is equilateral with side length $4$. Constraints: For $100\%$ of the testdata, it is guaranteed that $3 \le n \le 40$, $1 \le l_i \le 40$. Translated by ChatGPT 5