Files
contests/2023/rcpc/d2/editorial/g-minimize-sum-31.cpp
2024-04-22 16:45:09 +03:00

40 lines
549 B
C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#warning That's the baby, that's not my baby
typedef long long ll;
void solve() {
int n;
std::cin >> n;
ll sum = 0;
int maxi = 0;
for (int i = 0; i < n; i++) {
int x;
std::cin >> x;
if (i != n - 1) {
sum += x;
maxi = std::max(maxi, x);
}
}
std::cout << sum - maxi << '\n';
}
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(0);
int t;
std::cin >> t;
while (t--) {
solve();
}
return 0;
}