#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    int f = 0;
    for (int i = 0; i < n; i++) {
      int s;
      cin >> s;
      f += s;
    }
    cout << min(f, m) << "\n";
  }
}
