Find Minimum and MaximumEasy

Find Minimum and Maximum

EasyPractice library · +10 XParraysmin-max

Given a list of N integers, find the smallest (minimum) and the largest (maximum) integer in the list. Print the minimum value followed by the maximum value, separated by a space.

Input

The first line contains an integer N. The second line contains N space-separated integers.

Output

Print two space-separated integers: the minimum value and the maximum value from the input list.

Constraints

1 <= N <= 1000 -10^9 <= A[i] <= 10^9, where A[i] is the i-th integer.

Time limit 1 s (native code; slower languages get more)Memory 256 MB14 hidden tests

Example 1

Input
5
10 4 8 15 3
Output
3 15

The minimum is 3 and the maximum is 15.

Example 2

Input
3
-5 -1 -10
Output
-10 -1

The minimum is -10 and the maximum is -1.

Hints