-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path귀찮아 (SIB).java
More file actions
30 lines (24 loc) · 808 Bytes
/
귀찮아 (SIB).java
File metadata and controls
30 lines (24 loc) · 808 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
// 귀찮아 (SIB)
import java.util.*;
import java.lang.*;
import java.io.*;
class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
StringTokenizer st = new StringTokenizer(br.readLine());
int[] arr = new int[n];
if (n == 1) {
System.out.println(0);
return;
}
long allSum = 0, eachSum = 0;
for (int i = 0; i < n; i++) {
arr[i] = Integer.parseInt(st.nextToken());
allSum += arr[i];
eachSum += (long) arr[i] * arr[i];
}
allSum *= allSum;
System.out.println((allSum - eachSum) / 2);
}
}