Given a sorted array of positive integers. Your task is to find whether an element exists in the array from where number of smaller elements is equal to number of greater elements.

**Input:**

The first line of input contains **T** denoting the no of test cases . Then **T** test cases follow. The first line of each test case contains an integer **N** and the next line contains **N** space separated array elements.

**Output:**

For each test case output the required equal point. If Equal Point appears multiple times in input array, print the index of its first occurrence. If Equal Point doesn't exists then print "-1" (without quotes).

**Constraints:**

1 <= T <= 100

1 <= N <= 10^{7}

1 <= A_{i} <= 10^{18}

**Example:
Input:**

2

6

1 2 3 3 3 3

8

1 2 3 3 3 3 4 4

**Output:**

1

-1

**Explanation:
Testcase1: **2 is the element before which we have 1 element that is smaller than 2 and we have 1 element to its right which is greater than 2. Print index of 2.

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

codersanjeev | 66 |

snow_den_ | 60 |

BoggavarapuRamSaranSaiSrinivasGupta | 60 |

rajupraaa1234 | 53 |

SUZAKU | 49 |

mr_kksparrow | 433 |

manvirag982 | 258 |

snow_den_ | 232 |

arpit_anshuman | 228 |

SoumyaKaushik | 205 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.