fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int n;
  7. cin>>n;
  8. vector<int>v(n);
  9. for(int i=0;i<n;i++){
  10. cin>>v[i];
  11. }
  12. sort(v.begin(),v.end());
  13. //for(int i=n-1;i<)
  14. v.erase(v.begin()+n-1);
  15.  
  16. int sum=0;
  17. int x=accumulate(v.begin(),v.end(),sum);
  18. cout<<x;
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0s 4464KB
stdin
8
15 -2 2 -8 1 7 10 23
stdout
25