841. Spike Element

0

Easy

A

**Spike**element is defined as an element in an array that is strictly greater than both of its neighbors. The first and last elements of the array cannot be spike elements. Given a 0-indexed integer array Arr, find a spike element and print its index. If there are multiple spike elements, print the index of the first spike element encountered from the start of the array. If there is no spike element in the array, print -1.Input Format

The first line contains a single integer N, which represents the size of the array.
The second line consists of N space-separated integers, representing the elements of the array.

Output Format

Print the index of the spike element.

Example

Input

4
1 2 3 2

Output

2

Constraints

1 <= N <= 10

Solve the problem with a time complexity of O(LogN)

^{4}Solve the problem with a time complexity of O(LogN)

Loading...

View Submissions

Console