#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, m;
  scanf("%d", &t);
  while (t--) {
    scanf("%d%d", &n, &m);
    int sum = 0;
    for (int i = 0; i < n; ++i) {
      int x;
      scanf("%d", &x);
      sum += x;
    }
    printf("%d\n", min(sum, m));
  }
  return 0;
}
