Difficult times lie ahead of Ivica and his Holding – a group of Croatian companies that are in his ownership. Each of these companies is in debt so the state sent its attorneys to take everything away from him. We have exclusively found out that Ivica managed to make a deal with the state to leave him certain companies in spite of the massive debt. Which ones? We found that out as well.
The state attorneys have laid out proprietary papers of Ivica's companies on the table. The debt of first company is written on the first paper , the debt of the second company is written on , … and the debt of the last company is written on the last paper . Ivica made a deal with the state to leave the companies in his ownership, where and represent the positions in an array of papers on the table. Fortunately for Ivica, the attorneys are (also) corrupt. They will force him to take the same contiguous subarray as agreed upon (from -th to -th paper), but they will let him swap any two papers on the table for a specific cost. More precisely, swapping papers at positions and will cost him kunas (Croatian currency). Ivica is desperate. He has only kunas in his pocket which he now wishes to spend in such a way that the sum of debts of companies he is left with is as small as possible.
Help Ivica achieve his goal.
Input
The first line contains four space-separated integers and from the task description.
The second line contains integers from the task description.
Output
You should output a single integer which represents the smallest amount of total debt Ivica will have if he spends his kunas optimally.
Scoring
Subtask | Score | Constraints |
---|---|---|
and | ||
and | ||
No additional constraints. |
Sample Input 1
3 2 2 1
1 2 3
Sample Output 1
1
Sample Input 2
5 2 3 3
21 54 12 2 0
Sample Output 2
12
Sample Input 3
6 4 6 100
1 2 3 4 5 6
Sample Output 3
6
Comments