시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB62233.333%

## 문제

The code for getMin( ) function is shown below. Given an integer n and an array of integers arr, you have to write the rearrange( ) function which will be called by the getMin( ) function so that your rearrange( ) function minimize the return value from the getMin( ) function.

int getMin(int n, int arr[]){
arr2 = rearrange(arr);
for(int i = 0; i < arr2.length(); i = i+1){
n = n-arr2[i];
if (n <= 0) break;
}
return n;
}

Your rearrange( ) function should get an array of integers as an input and then return a new array of integers. The new array must contain the same members of the old array but the position of each member may be changed.

In this contest, the judges do not care about how you code the rearrange( ) function. You just have to submit the minimum return value of thegetMin( ) function to win the contest.

## 입력

The first line will contain the number of test cases T. (1 ≤ T ≤ 10)

For each test case, there will be 2 lines. The first line of each test case contains 2 integers, n (0 ≤ n ≤ 10 000) and k (0 ≤ k ≤ 10 000), the length of array arr. The second line contains the members of array arr, arr, ... , arr[k-1] (0 ≤ arr[i] ≤ 1 000 000). There will be exactly k integers in this line. Each integer is separated with a space.

## 출력

For each test case, print the minimum return value from getMin( ) function, one test case per line.

## 예제 입력 1

2
5 4
1 2 3 4
100 3
70 60 80


## 예제 출력 1

-3
-50


## 힌트

Explanation for sample test case 2: you send [70, 60, 80] to the rearrange( ) function and it returns [80, 70, 60]. There can be more than one ways to rearrange the array arr in order to minimize the getMin( ) function’s return value.