#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d, maxans;
int main() {
  cin >> a;
  for (int i = 0; i < a; i++) {
    d = 0;
    cin >> b >> maxans;
    for (int j = 0; j < b; j++) {
      cin >> c;
      d += c;
    }
    cout << min(maxans, d) << endl;
  }
  return 0;
}
