#include using namespace std; #define Loop(x,l,r) for (ll x = ll(l); x < ll(r); ++x) #define LoopR(x,l,r) for (ll x = ll(r)-1; x >= ll(l); --x) #define Looc(x,l,r) for (ll x = ll(l); x <= ll(r); ++x) #define LoocR(x,l,r) for (ll x = ll(r); x >= ll(l); --x) #define int ll typedef long long ll; typedef pair pii; typedef pair pll; #ifndef DB #define DB 0 #define endl '\n' #endif #define debugl(l) if constexpr ((l) < DB) #define debug debugl(0) void solve() { int n; cin >> n; vector a(n); for (auto &x : a) cin >> x; sort(a.begin(), a.end()); ll sum = 0; Loop (i,0,n-1) sum += a[i]; a.back() = min(a.back(), sum+1); sum += a.back(); cout << sum << '\n'; } signed main() { cin.tie(0) -> sync_with_stdio(false); int t = 1; cin >> t; while (t--) solve(); }