Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <queue>
- #include <cstring>
- using namespace std;
- typedef long long ll;
- const int maxn = 2e5 + 10;
- const ll MOD = 1e9 + 7;
- int main() {
- ios_base::sync_with_stdio(false);
- int n;
- cin >> n;
- vector<int> v(n);
- for(int i = 0; i < n; i++) {
- cin >> v[i];
- }
- sort(v.begin(), v.end());
- ll sum = 0;
- for(int i = 0; i < n - 1; i++) {
- sum += v[i];
- }
- if(v[n - 1] > sum) {
- cout << v[n - 1] * 2 << endl;
- }
- else {
- cout << sum + v[n - 1] << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement