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 identical sectors, numbered from to in clockwise order. The th sector has a value of , representing its effectiveness on your friend.
Initially, each sector is occupied by a circular pie, with the pie in the th sector having a value of . At the end of a round, each pie moves to the next sector in clockwise order.
During each round, you will pick an unselected sector. If you pick sector , and pie is currently occupying it, your score for that round is . Your total score is the sum of your scores for each round.
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 is the following:
Round : Pick sector giving
Round : Pick sector giving
Round : Pick sector giving
Round : Pick sector giving
Comments