#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int n, m, i;
    cin >> n >> m;
    long long int a[n];
    for (i = 0; i < n; i++) cin >> a[i];
    long long int sum = 0;
    for (i = 1; i < n; i++) sum += a[i];
    long long int diff = m - a[0];
    if (diff <= sum)
      cout << m << "\n";
    else
      cout << sum + a[0] << "\n";
  }
  return 0;
}
