package ACW;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n= scan.nextInt();
int num[] = new int[n];
int ans=0;
for(int i=0;i<n;i++){
num[i]= scan.nextInt();
}
Arrays.sort(num);
for(int i =0;i<n-1;i++){
ans+=num[0]+num[1];
int tmp=num[0]+num[1];
num[0]=100005;
num[1]=tmp;
Arrays.sort(num);
}
System.out.println(ans);
}
}
06-17
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountBlack.png)
11-17
1108
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountBlack.png)
09-10
527
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountBlack.png)
09-07
494
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountBlack.png)