#include <bits/stdc++.h>
signed main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  long long int t;
  std::cin >> t;
  std::vector<long long int> answerVector;
  for (long long int j = 0; j < t; j++) {
    long long int n, m;
    std::cin >> n >> m;
    std::vector<long long int> s;
    for (long long int j = 0; j < n; j++) {
      long long int k;
      std::cin >> k;
      s.push_back(k);
    }
    long long int sum = 0;
    for (long long int j = 1; j < n; j++) {
      sum += s[j];
    }
    if (sum + s[0] <= m) {
      answerVector.push_back(sum + s[0]);
    } else {
      answerVector.push_back(m);
    }
  }
  for (long long int j = 0; j < t; j++) {
    std::cout << answerVector[j] << "\n";
  }
  return 0;
}
