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.

**Input:**

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.

**Output:**

For each test case, in a new line print the required element. If no such element present in array then print -1.

**Constraints:**

1<=T<=100

3<=N<=10^{6}

1<=A[i]<=10^{6}

**Example:
Input:**

3

4

4 2 5 7

3

11 9 12

6

4 3 2 7 8 9

**Output:**

5

-1

7

Author: arun03

vegascrew | 179 |

ADI_MUNDI | 172 |

Deepak Rikhari | 171 |

Rajat Thakur 2 | 169 |

ground_zero | 164 |

white walker | 679 |

stevecooper | 625 |

BST | 604 |

Survivor | 552 |

chacha_vidhayak_hai_hmare | 551 |

akhayrutdinov | 4616 |

Ibrahim Nash | 3662 |

sanjay05 | 3633 |

Quandray | 3343 |

surbhi_7 | 2543 |