1367 - Network

Time Limit: 2s Memory Limit: 256MB

Submissions: 71 Solved: 10
If you had participated in CUGPC(CUG Programming Contest) 2009, you should remember that we had a problem to transfer data in a computer network. This time, we found a new problem. This problem is: There are some computers in the computer room, which are placed in a line way and every two neighboring computers are connected by local area network. Each computer can exchange data with another one. However, once you need to exchange data between two computers, the cost is the product of the amount of the exchanging data in the two computers multiple the communicating distance between the two. Your task is to find out the maximum cost in all pairs of computers. For example, in Fig1, the maximum cost of exchanging data is between computer No.2 and computer No.5, and the cost is the product of the amount of exchanging data 10 * 13 multiple the communicating distance 1+2+1=4, so the answer of Fig 1 is 10 * 13 * 4= 520.
The input consists of multiple test cases. For each test case, the first line contains a integer N(2 ≤ N ≤ 50000) , the number of computers, followed by two lines. Each line contains N real numbers not integers. And the ith number of the first line indicates the amount of data stored in the computer i. The ith number of the second line, in increasing order, indicates the coordinate of the computer i on the line. Computer i is connected with computer i-1 and i+1.
For each test case, just output one line contains a single number, the maximum cost. Round the numbers in the output to 6 digits after decimal point.
Sample Input
1.0  10.0  5.0  9.0  13.0
0.0  1.0  2.0  4.0  5.0
Sample Output