Find Minimum In Rotated Sorted Array

easy
1. Suppose an array sorted in ascending order is rotated at some pivot unknown to you.
 EXAMPLE:[0,1,2,4,5,6,7] might become  [4,5,6,7,0,1,2]).
 2. Find the minimum element.
 3. You may assume no duplicate exists in the array.

Input Format

First line contains N. Second line contains N space separated integers.

Output Format

Return the integer.

Constraints

1<=N<=10^7

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
7
4 5 6 7 0 1 2
Output
0
Previous
Find K Closest Elements
Next
Find Transition Point

Related Questions