-
Notifications
You must be signed in to change notification settings - Fork 0
/
Reading Books.cpp
96 lines (80 loc) · 3.21 KB
/
Reading Books.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/// say Alhamdulillah
#include <bits/stdc++.h>
using namespace std;
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(0);
// cout.tie(0);
#define ll long long
// #define init \
// ll count = 0, zz, t; \
// cin >> t; \
// while (t--)
#define ld long double
#define ed "\n"
#define eb emplace_back
#define con continue
#define bre break
#define pl " "
#define pll " --- "
// #define size size()
#define mpr make_pair
#define vec vector<ll>
#define lmax LONG_LONG_MAX
#define lmin LONG_LONG_MIN
#define forr(i, a, b) for (ll i = a; i < b; i++)
#define forrev(i, a, b) for (ll i = a; i >= b; i--)
// #define v.all v.begin(), v.end()
#define printArrWhole(arr, n) \
for (ll i = 0; i < n; i++) \
cout << arr[i] << " "; \
cout << endl;
#define printArrLim(arr, in, n) \
for (ll i = in; i <= n; i++) \
cout << arr[i] << " "; \
cout << endl;
#define printYesNo(flag) \
if (flag == 0) \
cout << "NO"; \
else \
cout << "YES"; \
cout << endl;
#define printvcWhole(vc) \
for (auto x : vc) \
cout << x << " "; \
cout << endl;
#define printvcLim(vc, in, n) \
for (ll i = in; i <= n; i++) \
cout << vc[i] << " "; \
cout << endl;
#define printdqWhole(dq) \
for (auto x : dq) \
cout << x << " "; \
cout << endl;
#define printdqLim(dq, in, n) \
for (ll i = in; i <= n; i++) \
cout << dq[i] << " "; \
cout << endl;
#define sortArr(arr, n) sort(arr, arr + n);
#define sortvc(v) sort(v.begin(), v.end());
#define rev(v) reverse(v.begin(), v.end());
// #define find(v, x) find(v.begin(), v.end(), x);
int main() {
ll n, ans, k, x;
cin >> n;
vector<ll> v;
for (ll i = 1; i <= n; i++) {
cin >> x;
v.eb(x);
}
sort(v.begin(), v.end());
x = 0;
for (ll i = 0; i < n - 1; i++) {
x += v[i];
}
if (x > v.back())
cout << x + v[n - 1];
else
cout << x + v[n - 1] + abs(x - v[n - 1]);
return 0;
}