#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fi first
#define se second
#define For(i, l, r) for (auto i = (l); i < (r); i++)
#define ForE(i, l, r) for (auto i = (l); i <= (r); i++)
#define FordE(i, l, r) for (auto i = (l); i >= (r); i--)
#define Fora(v, a) for (auto v: (a))
#define bend(a) (a).begin(), (a).end()
#define isz(a) ((signed)(a).size())
using ll = long long;
using ld = long double;
using pii = pair <int, int>;
using vi = vector <int>;
using vpii = vector <pii>;
using vvi = vector <vi>;
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
// freopen("KEK.inp", "r", stdin);
// freopen("KEK.out", "w", stdout);
int n; cin >> n;
vi a(n);
For(i, 0, n){
cin >> a[i];
}
sort(bend(a));
ll ans = 0;
For(i, 1, n){
ans += a[0] + a[i];
}
cout << ans << endl;
}
/*
==================================================+
INPUT |
--------------------------------------------------|
--------------------------------------------------|
==================================================+
OUTPUT |
--------------------------------------------------|
--------------------------------------------------|
==================================================+
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
6 ms |
844 KB |
Output is correct |
3 |
Correct |
17 ms |
1620 KB |
Output is correct |
4 |
Correct |
16 ms |
1468 KB |
Output is correct |
5 |
Correct |
12 ms |
1596 KB |
Output is correct |
6 |
Correct |
10 ms |
1492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
328 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
6 ms |
844 KB |
Output is correct |
3 |
Correct |
17 ms |
1620 KB |
Output is correct |
4 |
Correct |
16 ms |
1468 KB |
Output is correct |
5 |
Correct |
12 ms |
1596 KB |
Output is correct |
6 |
Correct |
10 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
316 KB |
Output is correct |
21 |
Correct |
6 ms |
852 KB |
Output is correct |
22 |
Correct |
16 ms |
1708 KB |
Output is correct |
23 |
Correct |
14 ms |
1604 KB |
Output is correct |
24 |
Correct |
19 ms |
1576 KB |
Output is correct |
25 |
Correct |
17 ms |
1596 KB |
Output is correct |
26 |
Correct |
16 ms |
1492 KB |
Output is correct |
27 |
Correct |
16 ms |
1604 KB |
Output is correct |
28 |
Correct |
16 ms |
1480 KB |
Output is correct |
29 |
Correct |
19 ms |
1584 KB |
Output is correct |
30 |
Correct |
14 ms |
1616 KB |
Output is correct |