403155: GYM101047 K Training with Phuket's larvae

Memory Limit:64 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

K. Training with Phuket's larvaetime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard output

Thai cuisine is known for combining seasonings so that every dish has flavors that are sweet (sugar, fruits, bell peppers), spicy, sour (vinegar, tamarind, lime), and salty (soy sauce, fish sauce). The most exotic dish, however, is the one containing fried insect larvae; naturally, it is often showcased to tourists. Westerners usually shudder at the thought of eating larvae, but they are highly valued in Thailand and they are a huge success in parties. Thai children often play with food. They specially like building triangles up using fried larvae as the edges.

Marcos "the (Rubik) solver" coaches his university's team on a famous computer programming contest. Next year, the contest's world finals will take place in Phuket, Thailand.

Marcos knows how Thai children like to play with larvae, so he had an idea for a special training session. His idea involves preparing a large amount of fried larvae of several different lengths. Each of his friends, in turn, must select three larvae to build a triangle. Then, the amount of fried larvae each friend has to eat is proportional to the area of the triangle she or he built.

Marcos hopes that, since you want to eat as little larvae as possible, you'll write a program to choose the larvae that forms a triangle of minimum area. Thus, besides training your computer programming skills, you'll also be training to face Thai cuisine. If you actually enjoy this dish, you may use this program to help your other friends, making sure that there will be more fried larvae left for you.

Input

The first line has a single integer T, the number of test cases.

Each test case starts with an integer N, the number of larvae. In the next line there are N space-separated real numbers a1, ..., an, representing the lengths of the larvae.

Limits

  • 1 ≤ T ≤ 30
  • 1 ≤ N ≤ 2·103
  • 1 ≤ ai ≤ 500
  • The sum of N over all test cases will not exceed 6·103
Output

For each test case, print a single line containing the minimum area for that case, the error should not exceed 10 - 4; if it is not possible to build a triangle from the larvae, print -1.

ExampleInput
3
4
3 4 5 6
3
1 2 4
5
3.4 2.8 7.1 5.2 10
Output
5.3326822519
-1
4.3599885321

Source/Category

加入题单

算法标签: