fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const int Mod=998244353;
  5. const ll INF = -10000000000000;
  6.  
  7. void solve() {
  8. int n;
  9. cin >> n;
  10. vector<int> a(n);
  11. for(int i=0;i<n;i++) cin >> a[i];
  12. ll ans = a[n-1];
  13. for(int i=0;i<n-2;i++) ans+=a[i];
  14. cout << ans - a[n-2] << '\n';
  15. }
  16.  
  17. int main(){
  18. ios::sync_with_stdio(false);
  19. cin.tie(nullptr);
  20.  
  21. int t;
  22. cin >> t;
  23. while (t--) solve();
  24.  
  25.  
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0.01s 5324KB
stdin
5
2
2 1
3
2 2 8
4
1 2 4 3
5
1 2 3 4 5
5
3 2 4 5 4
stdout
-1
8
2
7
8