#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, r;
  int m;
  cin >> t;
  for (int j = 0; j < t; j++) {
    int sum = 0;
    cin >> n >> m;
    for (long long int i = 0; i < n; i++) {
      cin >> r;
      sum = min(sum + r, m);
    }
    cout << sum << endl;
  }
  return 0;
}
