|All-time Popular Problems|
|Max sum in the configuration|
|Searching a number|
|Immediate Smaller Element|
|Next greater number set digits|
|Lowest Common Ancestor in a BST|
|Largest Number formed from an Array|
|Leaders in an array|
|Add two numbers represented by linked lists|
|Reverse words in a given string|
Given an unsorted array of size N. Find the first element in array such that all of its left elements are smaller and all right elements to it are greater than it.
Note: Left and right side elements can be equal to required element. And extreme elements cannot be required element.
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consists of two lines. First line of each test case contains an Integer N denoting size of array and the second line contains N space separated array elements.
For each test case, in a new line print the required element. If no such element present in array then print -1.
4 2 5 7
11 9 12
4 3 2 7 8 9