#include <bits/stdc++.h>
using namespace std;
int t, n, m, a[1007];
int main() {
  ios::sync_with_stdio(false);
  cin >> t;
  while (t--) {
    cin >> n >> m;
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      cnt += a[i];
    }
    if (m <= cnt)
      cout << m << endl;
    else
      cout << cnt << endl;
  }
  return 0;
}
