#include <bits/stdc++.h>
using namespace std;
void faster() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
const long long INF = 1e9;
const long long MAXN = 2e5 + 1;
const long long MAXM = 1e6 + 1;
long long n, m, sum, a[MAXN];
void solve() {
  sum = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    sum += a[i];
  }
  sum -= a[1];
  cout << min(m, sum + a[1]) << '\n';
}
int main() {
  faster();
  int T = 1;
  cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}
