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