Sort Master Bae Jihoon

Interview

Time limit1sMemory limit256 MB

Summary
Given N integers, print the largest value, which is the last element after sorting in ascending order.
Level

Easy1 of 10

Topics
Array, Implementation
Solved
No attempts yet

Problem

Jihoon is a Sort master. He claims that no matter what array of N elements he is given, he can sort it in ascending order in his head. The skeptical Boseong decides to test Jihoon. However, checking every single element is too much trouble, so Boseong decides to check only whether the last element of the sorted array is correct.

Write a program that tells Boseong the last element.

Input

The first line gives N. (1 ≤ N ≤ 500,000)

The next line gives N integers A[1], A[2], ... , A[N]. (0 ≤ A[i] ≤ 10^9)

Output

Print the last element of the sorted array A on the first line.

Examples1

  1. Example 1

    Input
    3
    3 2 1
    
    Expected output
    3