#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  long long int n, m;
  while (t--) {
    cin >> n >> m;
    long long int arr[n];
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
    }
    long long int sum = 0;
    for (int i = 1; i < n; i++) {
      sum += arr[i];
    }
    if (sum + arr[0] >= m) {
      cout << m << "\n";
    } else {
      cout << sum + arr[0] << "\n";
    }
  }
}
