Binary Search

MediumGrade 12

The array is already sorted ascending. Implement binary search to find the target's index (or -1 if absent) without scanning every element.

Input / Output

Input: first line N, second line N sorted space-separated integers, third line the target. Output: the 0-based index of target, or -1.

Examples

Input

5
1 3 5 7 9
7

Expected Output

2

Input

4
2 4 6 8
5

Expected Output

-1

+ 2 hidden tests checked on Submit.

Files

Main.java is the entry point. Add extra classes for OOP exercises — they compile together.

Main.java
Loading...

Run your code to see test results here.