You are trying to convince your friend to do your homework for you. Rather than bribing them like usual, you decide to persuade them using a new gadget you invented called the speech wheel.
The wheel is divided into
Initially, each sector is occupied by a circular pie, with the pie in the
During each round, you will pick an unselected sector. If you pick sector
A higher score means a greater probability to persuade your friend. Please find the maximum total score you can achieve if you continue until every sector has been picked.
For this problem, Python users are recommended to use PyPy.
Input Specification
The first line contains the integer
The next line contains the space-separated integers
The final line contains the space-separated integers
Output Specification
Output one line containing the maximum score you can achieve.
Sample Input
4
2 -1 1 -2
1 2 3 4
Sample Output
6
Explanation for Sample Output
One way to get a total score of
Round
Round
Round
Round
Comments