#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d, n, m, i, j, k, l, t, o, p;
int main() {
  cin >> t;
  for (j = 0; j < t; j++) {
    cin >> n >> m;
    cin >> c;
    b = 0;
    for (i = 1; i < n; i++) {
      cin >> a;
      b += a;
    }
    cout << min(b + c, m) << "\n";
  }
}
