-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlackSlexNumber.java
More file actions
29 lines (27 loc) · 989 Bytes
/
BlackSlexNumber.java
File metadata and controls
29 lines (27 loc) · 989 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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class BlackSlexNumber {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
String ln = br.readLine();
if (ln == null) return;
int t = Integer.parseInt(ln);
while (t-- > 0) {
int n = Integer.parseInt(br.readLine());
int[] a = new int[n];
StringTokenizer st = new StringTokenizer(br.readLine());
for (int i = 0; i < n; i++) {
a[i] = Integer.parseInt(st.nextToken());
}
Arrays.sort(a);
int opt1 = a[0];
int opt2 = a[1] - a[0];
sb.append(Math.max(opt1, opt2)).append("\n");
}
System.out.print(sb);
}
}