#include <bits/stdc++.h>
int main() {
  long long testcasees, students, maximum_marks, start, marks, sum = 0;
  scanf("%lld", &testcasees);
  while (testcasees--) {
    sum = 0;
    scanf("%lld %lld", &students, &maximum_marks);
    while (students--) {
      scanf("%lld", &marks);
      sum += marks;
    }
    if (sum >= maximum_marks)
      printf("%lld\n", maximum_marks);
    else
      printf("%lld\n", sum);
  }
  return 0;
}
