#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int test;
  cin >> test;
  while (test--) {
    int n, m;
    cin >> n >> m;
    int array[n];
    for (int i = 0; i < n; i++) cin >> array[i];
    int sum = 0;
    for (int i = 0; i < n; i++) {
      sum += array[i];
    }
    double average = sum / double(n);
    double value = m / double(n);
    if (value <= average)
      cout << m << endl;
    else
      cout << average * n << endl;
  }
}
