This page is still under construction.

Parts of this page are still being built. What you see may change.

Minimum and Maximum

Time limit1sMemory limit256 MB

Summary
Read N integers and print the smallest and the largest separated by a space.
Level

Easy1 of 10

Topics
Array
Solved
No attempts yet

Problem

You are given NN integers. Write a program that finds the smallest and the largest of them.

Input

The first line contains the number of integers NN (1≤N≤1061 \le N \le 10^6).

The second line contains the NN integers, separated by spaces. Each integer is at least −106-10^6 and at most 10610^6.

Output

Print the smallest and the largest of the NN given integers on the first line, separated by a single space.

Examples5

  1. Example 1

    Input
    5
    20 10 35 30 7
    
    Expected output
    7 35
    
  2. Example 2

    Input
    1
    0
    
    Expected output
    0 0
    
  3. Example 3

    Input
    1
    -1000000
    
    Expected output
    -1000000 -1000000
    
  4. Example 4

    Input
    2
    1000000 -1000000
    
    Expected output
    -1000000 1000000
    
  5. Example 5

    Input
    4
    -5 -5 -5 -5
    
    Expected output
    -5 -5