#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, t, m, k;
  string s;
  cin >> k;
  while (k--) {
    cin >> n >> m;
    long long sum = 0;
    for (long long i = 0; i < n; i++) {
      cin >> t;
      sum += t;
    }
    cout << min(m, sum) << "\n";
  }
}
