Given an array **A** of **N** positive numbers. The task is to find the position where equilibrium first occurs in the array. Equilibrium position in an array is a position such that the sum of elements below it is equal to the sum of elements after it.

**Input:**

The first line of input contains an integer **T**, denoting the number of test cases. Then T test cases follow. First line of each test case contains an integer N denoting the size of the array. Then in the next line are N space separated values of the array A.

**Output:**

For each test case in a new line print the position at which the elements are at equilibrium if no equilibrium point exists print -1.

**Constraints:**

1 <= T <= 100

1 <= N <= 10^{6}

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

**Example:
Input:**

2

1

1

5

1 3 5 2 2

**Output:**

1

3

**Explanation:**

**Testcase 1:** Since its the only element hence its the only equilibrium point.

**Testcase 2:** For second test case equilibrium point is at position 3 as elements below it (1+3) = elements after it (2+2).

blackshadows | 242 |

xmyqsh | 216 |

hanuman001 | 172 |

Adarsh Trivedi | 168 |

layman_brother | 168 |

blackshadows | 724 |

xmyqsh | 557 |

aman19 | 402 |

r0c2048 | 360 |

kspk | 331 |

akhayrutdinov | 5005 |

Ibrahim Nash | 4871 |

Quandray | 4338 |

sanjay05 | 3668 |

blackshadows | 3228 |

Login to report an issue on this page.