Rahul and his friends decided to play a game in a New Year Party and the winner will be given some cash prize as decided among them.The game is as follows:-

1.N carpets will be arranged in a row and each of them will have a number written on it.

2.A basket full of chocolate is kept there and a person has to take out M chocolates from the basket before starting the game.

3.A person with M chocolates will start at the first carpet ,eat one chocolate and move to the second one,then again eat one chocolate and move to the third one...and so on..

4.If on reaching any carpet ,the number of chocolates in the persons hand is less than the number written on the carpet ,then that person loses the game.

Find the minimum number of chocolate Rahul should take out of the basket to ensure that he wins the game.

Note:Number of chocolates and the number written on the carpet are compared before the person eats the chocolate on that carpet.See the examples given :)

**Input:**

The first line of the input contains an integer **T** denoting the number of test cases. The first line of each test case contains a single integer **N** denoting the number of carpets. The second line contains **N** space-separated integers **W _{1}**,

**Output:**

For each test case, output a single line containing the minimum numer of chocolate Rahul should take out of the basket.

**Constraints:**

**1**≤**T**≤**10****1**≤**N**≤**10^5****1**≤**W**≤_{i}**10^6**

**Example**

**Input:**
2
5
6 5 4 3 2
5
3 4 3 1 1
**Output:**
6
5

Test case 1:

If Rahul takes 6 chocolates, on the first step we have 6 >= 6 everything is OK, then after he ate one chocolate , the chocolates decreased to 5 and on the 2nd carpet we'll receive 5 >= 5, again OK, and so on.

Test case 2:

If Rahul takes 4 chocolates, then he will loose the game on reaching the 2nd carpet .

Author: Riya Bhardwaj

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.

Sulagna | 117 |

RUTVIKHARIPARA | 116 |

janvidavda105190 | 93 |

harshsiddhapura105461 | 93 |

devsinghindra | 80 |

PiyushPandey4 | 614 |

ASWATHAMA | 561 |

akhyasharma01 | 547 |

john_wick | 521 |

jagrit_07 | 443 |

blackshadows | 5362 |

Ibrahim Nash | 5242 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4598 |

Login to report an issue on this page.