$n$ students are taking an exam. The highest possible score at this exam is $m$. Let $a_{i}$ be the score of the $i$-th student. You have access to the school database which stores the results of all students.

You can change each student's score as long as the following conditions are satisfied:   All scores are integers  $0 \leq a_{i} \leq m$  The average score of the class doesn't change. 

You are student $1$ and you would like to maximize your own score.

Find the highest possible score you can assign to yourself such that all conditions are satisfied.


-----Input-----

Each test contains multiple test cases. 

The first line contains the number of test cases $t$ ($1 \le t \le 200$). The description of the test cases follows.

The first line of each test case contains two integers $n$ and $m$ ($1 \leq n \leq 10^{3}$, $1 \leq m \leq 10^{5}$)  — the number of students and the highest possible score respectively.

The second line of each testcase contains $n$ integers $a_1, a_2, \dots, a_n$ ($ 0 \leq a_{i} \leq m$)  — scores of the students.


-----Output-----

For each testcase, output one integer  — the highest possible score you can assign to yourself such that both conditions are satisfied._


-----Example-----
Input
2
4 10
1 2 3 4
4 5
1 2 3 4

Output
10
5



-----Note-----

In the first case, $a = [1,2,3,4] $, with average of $2.5$. You can change array $a$ to $[10,0,0,0]$. Average remains $2.5$, and all conditions are satisfied.

In the second case, $0 \leq a_{i} \leq 5$. You can change $a$ to $[5,1,1,3]$. You cannot increase $a_{1}$ further as it will violate condition $0\le a_i\le m$.

Difficulty: interview

Starter code:

Solutions:
for _ in range(int(input())):
    n, m = map(int, input().split())
    l1 = list(map(int,input().split()))
    print(min(sum(l1),m))

q = int(input())
for rwer in range(q):
	n,m = map(int,input().split())
	l = list(map(int,input().split()))
	print(min(m, sum(l)))

import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def solve():
    n,m = list(map(int, input().split()))
    a = list(map(int, input().split()))
    ans = min(sum(a), m)
    print(ans)

t = int(input())
for i in range(t):
    solve()


#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
t=int(input())
for tt in range(t):
    #n=int(input())
    n,m= map(int, sys.stdin.readline().split(' '))
    a=list(map(int,sys.stdin.readline().split(' ')))
    s=sum(a)-a[0]

    print(min(m,a[0]+s))
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return list(map(int, input().split()))
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
# sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

for _ in range(INT()):
    N, K = MAP()
    A = LIST()

    print(min(sum(A), K))


from math import *

T = int(input())
while T:
    T -= 1
    n, m = list(map(int, input().split()))
    a = list(map(int, input().split()))
    if sum(a) >= m:
        print(m)
    else:
        print(sum(a))


t=int(input())
while t:
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    print(min(sum(a),m))
    t-=1

from math import *

zzz = int(input())
for zz in range(zzz):
    n, m = list(map(int, input().split()))
    a = [int(i) for i in input().split()]
    print(int(min(sum(a), m)))




"""
NTC here
"""
import sys
inp = sys.stdin.readline
def input(): return inp().strip()
# flush= sys.stdout.flush
# import threading
# sys.setrecursionlimit(10**6)
# threading.stack_size(2**26)


def iin(): return int(input())


def lin(): return list(map(int, input().split()))


def main():
    T = iin()
    while T:
        T-=1
        n, m = lin()
        a = lin()
        ans = sum(a)
        print(min(ans, m))


main()

# threading.Thread(target=main).start()


"""
1
5
1 3
1 4
1 6
2 6
0 5
"""

t = int(input())
for _ in range(t):
  n,m = list(map(int,input().split()))
  s = list(map(int,input().split()))
  print(min(m,sum(s)))


import sys
input=sys.stdin.readline
t=int(input())
while(t):
    t-=1
    n,m=list(map(int,input().split()))
    a=list(map(int,input().split()))
    if(sum(a)>=m):
        print(m)
    else:
        print(sum(a))


import string


def main():
    n, m = list(map(int, input().split()))
    lst = list(map(int, input().split()))
    sm = 0
    for i in lst:
        sm += i
    print(min(sm, m))


def __starting_point():
    t = int(input())
    for i in range(t):
        main()

__starting_point()

from math import ceil,sqrt,gcd,log,floor
from collections import deque
def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().strip().split(" "))
def li(): return list(mi())
def msi(): return map(str,input().strip().split(" "))
def lsi(): return list(msi())
for _ in range(ii()):
    n,m=mi()
    a=li()
    s=a[0]+sum(a[1:])
    print(min(s,m))

import math,sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
li = lambda:list(map(int,input().split()))

def case():
    n,m=li()
    a=li()
    s=sum(a)
    print(min(s,m))

for _ in range(int(input())):
    case()