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