Given an array of positive integers and two positive integers **K1** and **K2**. Find sum of all elements greater tha K_{1}^{th} and smaller than K_{2}^{th} smallest elements of array.

**Input:**

The first line of input contains an integer **T** denoting the number of test cases. Then **T** test cases follow. Each test case contains an integer **N**, denoting the length of the array. Next line contains **N** space seperated integers of the array. Third line contains two space seperated integers denoting K_{1}^{th} and K_{2}^{th} smallest elements.

**Output:**

For each test case, output the sum of all the elements between K_{1}^{th} and K_{2}^{th} smallest elements.

**Constraints:**

1 <= T <= 100

1 <= N <= 10^{7}

1 <= K_{1}, K_{2} <= 10^{14}

**Example:**

**Input**

2

7

20 8 22 4 12 10 14

3 6

6

10 2 50 12 48 13

2 6

**Output:**

26

73

**Explanation:**

**Test Case 1:**

3rd smallest element is 10

6th smallest element is 20

Sum of all element between K1 & K2 is 12 + 14 = 26

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

thanuvinu94 | 238 |

the_coder95 | 215 |

ShivayLamba | 208 |

sandeep.prajapati | 129 |

adityasuman2025 | 111 |

the_coder95 | 1441 |

RishabhTanwar1 | 1110 |

thanuvinu94 | 914 |

tathagat289 | 668 |

themanhasnoname | 620 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4897 |

Quandray | 4547 |

Login to report an issue on this page.