解题思路:
注意事项:
参考代码:import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class T1462 {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
while(in.hasNext()) {
int n = in.nextInt();
ArrayList list = new ArrayList<>();
for(int i = 0;i
list.add(in.nextInt());
int ans = 0;
while(list.size()>1) {
Collections.sort(list);
int tmp = list.get(0)+list.get(1);
list.add(tmp);
list.remove(0);
list.remove(0);
ans += tmp;
}
System.out.println(ans);
}
in.close();
}
}