Binary Search Basic

VERY EASY · C · 2000ms

Librarian Arif keeps book ID numbers sorted on the shelf. Given a visitor's requested ID, Arif wants to instantly report its shelf position, or say it isn't there. Read a sorted array of N integers and a query value X. Print the 1-indexed position of X if it exists, else print -1.

Input

Line1: N. Line2: N sorted integers. Line3: X.

Output

Position of X, or -1.

Constraints

1 ≤ N ≤ 10^5

Sample Input

5
2 4 6 8 10
8

Sample Output

4
main.c
Loading editor…

Write C, then Run (custom I/O) or Submit (sample tests). ⌘/Ctrl+Enter submits.

Binary Search Basic · DIU ContestHub