Skip to content
UPEEC

First and Last Position

Medium#searching#binary-search· solved by 0 · time limit 2.0 s

In a sorted array (with duplicates) find the first and last index of xx (0-based), or -1 -1.

Input

nn and the sorted array, then xx.

Output

Two indices.

Constraints

1≤n≤1051 \le n \le 10^5

Sample 1

Input

6
5 7 7 8 8 10
8

Output

3 4

Sample 2

Input

6
5 7 7 8 8 10
6

Output

-1 -1

Sign in or join free to run and submit your solution.