#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    int a = 0, sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> a;
      sum += a;
    }
    cout << (sum > k ? k : sum) << endl;
  }
  return 0;
}
