#include <bits/stdc++.h>
#define int long long
#define vi vector <int>
#define vv vector <vi>
#define pi pair <int, int>
#define vip vector <pi>
#define pb push_back
#define f first
#define s second
#define nl cout<<"\n"
using namespace std;
const int mod=1e9+7;
const double eps=1e-9;
const int N=1e5;
int n, d[N+5];
int sum=0;
void input()
{
cin >> n;
for(int i = 1; i <= n; i++) cin >> d[i], sum+=d[i];
}
void solve()
{
sort(d+1, d+n+1);
if(n==1) sum=0;
else sum+=d[1]*(n-2);
cout << sum;
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t=1;
// freopen("math.inp", "r", stdin);
// freopen("math.out", "w", stdout);
// cin >> t;
for(int i = 1; i <= t; i++)
{
input();
solve();
nl;
}
}
/*
6
a
b
c
d
e
f
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
7 ms |
1236 KB |
Output is correct |
3 |
Correct |
14 ms |
1880 KB |
Output is correct |
4 |
Correct |
14 ms |
1796 KB |
Output is correct |
5 |
Correct |
12 ms |
2004 KB |
Output is correct |
6 |
Correct |
10 ms |
1748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
7 ms |
1236 KB |
Output is correct |
3 |
Correct |
14 ms |
1880 KB |
Output is correct |
4 |
Correct |
14 ms |
1796 KB |
Output is correct |
5 |
Correct |
12 ms |
2004 KB |
Output is correct |
6 |
Correct |
10 ms |
1748 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
5 ms |
1236 KB |
Output is correct |
22 |
Correct |
14 ms |
1868 KB |
Output is correct |
23 |
Correct |
11 ms |
1904 KB |
Output is correct |
24 |
Correct |
15 ms |
1932 KB |
Output is correct |
25 |
Correct |
17 ms |
1976 KB |
Output is correct |
26 |
Correct |
15 ms |
1876 KB |
Output is correct |
27 |
Correct |
17 ms |
1876 KB |
Output is correct |
28 |
Correct |
15 ms |
1808 KB |
Output is correct |
29 |
Correct |
16 ms |
1876 KB |
Output is correct |
30 |
Correct |
14 ms |
1828 KB |
Output is correct |