Largest and Smallest in Array

EasyBasics
Next
Array

Given an array of integers, print the largest value and the smallest value.

Input

Line 1: n, the number of elements. Line 2: n space-separated integers.

Output

Print the maximum and the minimum separated by a space.

Constraints

1 <= n <= 5 * 10^4 -10^9 <= each value <= 10^9

Example 1
Input
4
3 9 -2 7
Output
9 -2

9 is the largest and -2 is the smallest.

Hints

Largest and Smallest in Array - Easy Basics Problem | Skill Shiksha