#include <bits/stdc++.h>
using namespace std;
const int N = 5e6 + 5;
int solve() {
  int n, m, x, sum(0);
  cin >> n >> m;
  for (int i = 0; i < (int)n; i++) {
    cin >> x;
    sum += x;
  }
  return min(m, sum);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) cout << solve() << endl;
  return 0;
}
