-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ11399_0.java
More file actions
33 lines (24 loc) · 773 Bytes
/
Copy pathJ11399_0.java
File metadata and controls
33 lines (24 loc) · 773 Bytes
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
package TIL;
import java.io.*;
import java.util.*;
public class J11399_0 {
static LinkedList<Integer> A;
static int max;
public static void main(String[] args) throws IOException {
BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
int num = Integer.parseInt(buffer.readLine());
String[] input = buffer.readLine().split(" ");
A = new LinkedList<>();
for(int i =0; i <num; i++){
A.add(Integer.parseInt(input[i]));
}
Collections.sort(A);
int[] sum = new int[num+1];
int total = 0;
for(int i = 1; i<= num; i++){
sum[i] = sum[i-1]+A.get(i-1);
total += sum[i];
}
System.out.println(total);
}
}