#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k, a, sum(0);
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
      cin >> a;
      sum += a;
    }
    cout << min(sum, k) << endl;
  }
}
