#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int a, b;
    cin >> a >> b;
    int n;
    long long int sum = 0;
    for (int i = 0; i < a; i++) {
      cin >> n;
      sum += n;
    }
    if (sum <= b)
      cout << sum << endl;
    else
      cout << b << endl;
  }
  return 0;
}
