#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    int marks, i;
    int highest_marks, sum = 0;
    for (i = 0; i < n; i++) {
      cin >> marks;
      sum += marks;
    }
    if (sum <= m) {
      highest_marks = sum;
      cout << highest_marks << endl;
    } else {
      highest_marks = m;
      cout << highest_marks << endl;
    }
  }
  return 0;
}
