#include <bits/stdc++.h>
using namespace std;
long long int aa, a, b, c;
int main() {
  cin >> aa;
  while (aa--) {
    c = 0;
    cin >> a >> b;
    int f[a];
    for (int i = 0; i < a; i++) {
      cin >> f[i];
      c += f[i];
    }
    cout << min(c, b) << endl;
  }
}
