Subsequence Update
Time limit1.5sMemory limit2048 MB
Given an array and a segment [l,r], reverse one subsequence exactly once to find the minimum possible sum of the segment.
Problem
After Little John borrowed expansion screws from auntie a few hundred times, eventually she decided to come and take back the unused ones.
But as they are a crucial part of home design, Little John decides to hide some in the most unreachable places, under the eco-friendly wood veneers.
You are given an integer sequence and a segment ().
You must perform the following operation on the sequence exactly once.
- Choose any subsequence of the sequence and reverse it. The subsequence does not have to be contiguous.
Formally, choose any indices such that . Then change the -th element to the original value of the -th element simultaneously for all .
Find the minimum value of after performing the operation.
Input
Each test contains multiple test cases. The first line contains the number of test cases ().
The first line of each test case contains three integers , , (), the length of and the segment .
The second line contains integers ().
The sum of over all test cases does not exceed .
Output
For each test case, output the minimum value of on a separate line.
Hint
On the second test case, the array is and the segment is . After choosing the subsequence and reversing it, the sequence becomes . Then the sum becomes . It can be shown that the minimum possible value of the sum is .