-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBAEKJOON_1037
More file actions
38 lines (32 loc) · 1.06 KB
/
BAEKJOON_1037
File metadata and controls
38 lines (32 loc) · 1.06 KB
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
34
35
36
37
38
import java.io.*;
import java.sql.Array;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int N = Integer.parseInt(br.readLine());
int[] arr1 = new int[N];
int[] arr2 = new int[N];
StringTokenizer st = new StringTokenizer(br.readLine());
for(int i=0; i<N; i++){
arr1[i] = Integer.parseInt(st.nextToken());
}
Arrays.sort(arr1);
long result=0;
if(arr1.length==1){
result = (long)Math.pow(arr1[0], 2);
}
if(arr1.length >=2){
if(arr1.length %2!=0){
result=(long)Math.pow(arr1[arr1.length/2],2);
}else{
result = arr1[0] * arr1[N-1];
}
}
bw.write(String.valueOf(result));
bw.flush();
bw.close();
//System.out.println(Math.pow(3,2));
}
}