-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFindthePattern.java
44 lines (37 loc) · 1.43 KB
/
FindthePattern.java
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
39
40
41
42
43
44
/* IMPORTANT: Multiple classes and nested static classes are supported */
/*
* uncomment this if you want to read input.
//imports for BufferedReader
import java.io.BufferedReader;
import java.io.InputStreamReader;
//import for Scanner and other utility classes
import java.util.*;
*/
import java.util.*;
// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
class TestClass {
public static void main(String args[] ) throws Exception {
/* Sample code to perform I/O:
* Use either of these methods for input
//BufferedReader
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String name = br.readLine(); // Reading input from STDIN
System.out.println("Hi, " + name + "."); // Writing output to STDOUT
//Scanner
Scanner s = new Scanner(System.in);
String name = s.nextLine(); // Reading input from STDIN
System.out.println("Hi, " + name + "."); // Writing output to STDOUT
*/
// Write your code here
Scanner ob = new Scanner(System.in);
int N = ob.nextInt();
long max = ob.nextLong();
long min = max;
while(N-->1){
long x = ob.nextLong();
max=Math.max(max,x);
min=Math.min(min,x);
}
System.out.println((max+min));
}
}