LogiQuest

3. Binary Search

EasyBinary SearchArray

Given a sorted array of distinct integers and a value x, print the index of x, or -1 if it is not present. Aim for O(log n).

Input format

Line 1: n Line 2: n sorted distinct integers Line 3: x

Output format

The 0-based index of x, or -1.

Example 1

Input

6
-1 0 3 5 9 12
9

Output

4

Example 2

Input

6
-1 0 3 5 9 12
2

Output

-1

Constraints

1 ≤ n ≤ 10⁵

Read input from standard input and print the answer to standard output. Your code is judged against 6 test cases, most of them hidden.

Loading the MyLoginn IDE…