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