#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f;
const int MAX_N = 1000 + 5;
const double EPS = 1e-6;
int a[MAX_N];
int main(void) {
  int t, i;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    int sum = 0;
    for (i = 1; i < n; i++) sum += a[i];
    if (sum + a[0] > m)
      cout << m << endl;
    else
      cout << sum + a[0] << endl;
  }
}
