Under construction

Still being built. Things may change

Subsequence Update

Time limit1.5sMemory limit2048 MB

Summary
Given an array and a segment [l,r], reverse one subsequence exactly once to find the minimum possible sum of the segment.
Level

Medium6 of 10

Topics
Greedy, Sorting, Array
Solved
No attempts yet

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 a1,a2,…,ana_1, a_2, \ldots, a_n and a segment [l,r][l,r] (1≤l≤r≤n1 \le l \le r \le n).

You must perform the following operation on the sequence exactly once.

  • Choose any subsequence of the sequence aa and reverse it. The subsequence does not have to be contiguous.

Formally, choose any indices i1,i2,…,iki_1, i_2, \ldots, i_k such that 1≤i1<i2<…<ik≤n1 \le i_1 < i_2 < \ldots < i_k \le n. Then change the ixi_x-th element to the original value of the ik−x+1i_{k-x+1}-th element simultaneously for all 1≤x≤k1 \le x \le k.

Find the minimum value of al+al+1+…+ar−1+ara_l+a_{l+1}+\ldots+a_{r-1}+a_r after performing the operation.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤1041 \le t \le 10^4).

The first line of each test case contains three integers nn, ll, rr (1≤l≤r≤n≤1051 \le l \le r \le n \le 10^5), the length of aa and the segment [l,r][l,r].

The second line contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤1091 \le a_i \le 10^9).

The sum of nn over all test cases does not exceed 10510^5.

Output

For each test case, output the minimum value of al+al+1+…+ar−1+ara_l+a_{l+1}+\ldots+a_{r-1}+a_r on a separate line.

Hint

On the second test case, the array is a=[1,2,3]a=[1,2,3] and the segment is [2,3][2,3]. After choosing the subsequence a1,a3a_1, a_3 and reversing it, the sequence becomes [3,2,1][3,2,1]. Then the sum a2+a3a_2+a_3 becomes 33. It can be shown that the minimum possible value of the sum is 33.

Examples1

  1. Example 1

    Input
    6
    2 1 1
    2 1
    3 2 3
    1 2 3
    3 1 3
    3 1 2
    4 2 3
    1 2 2 2
    5 2 5
    3 3 2 3 5
    6 1 3
    3 6 6 4 3 2
    
    Expected output
    1
    3
    6
    3
    11
    8