Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- long long niza[n];
- for(int i = 0; i < n; i++)
- {
- cin >> niza[i];
- }
- sort(niza, niza + n);
- long long zbir = 0;
- for(int i = 0; i < n; i++)
- {
- zbir += niza[i];
- }
- zbir -= niza[n-1];
- if(niza[n-1] > zbir)
- {
- cout << niza[n-1] * 2 << endl;
- }
- else{
- cout << zbir + niza[n-1];
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement