#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d, e, f, g;
vector<int> v;
vector<int> v2;
vector<int> v3;
vector<int> ans;
int main() {
  int q;
  cin >> q;
  for (int k = 1; k <= q; k++) {
    cin >> a >> b;
    d = 0;
    for (int i = 1; i <= a; i++) {
      cin >> c;
      d += c;
    }
    if (d > b) {
      cout << b << '\n';
    } else
      cout << d << '\n';
  }
}
