#P1882C. Card Game

Card Game

No submission language available for this problem.

Description

There are nn cards stacked in a deck. Initially, aia_{i} is written on the ii-th card from the top. The value written on a card does not change.

You will play a game. Initially your score is 00. In each turn, you can do one of the following operations:

  • Choose an odd^{\dagger} positive integer ii, which is not greater than the number of cards left in the deck. Remove the ii-th card from the top of the deck and add the number written on the card to your score. The remaining cards will be reindexed starting from the top.
  • Choose an even^{\ddagger} positive integer ii, which is not greater than the number of cards left in the deck. Remove the ii-th card from the top of the deck. The remaining cards will be reindexed starting from the top.
  • End the game. You can end the game whenever you want, you do not have to remove all cards from the initial deck.

What is the maximum score you can get when the game ends?

^{\dagger} An integer ii is odd, if there exists an integer kk such that i=2k+1i = 2k + 1.

^{\ddagger} An integer ii is even, if there exists an integer kk such that i=2ki = 2k.

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1041 \le t \le 10^{4}). The description of the test cases follows.

The first line of each test case contains a single integer nn (1n21051 \le n \le 2 \cdot 10^{5}).

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (109ai109-10^{9} \le a_i \le 10^{9}).

It is guaranteed that the sum of nn over all test cases does not exceed 21052 \cdot 10^{5}.

For each test case, print a single integer — the maximum score you can get when the game ends.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1041 \le t \le 10^{4}). The description of the test cases follows.

The first line of each test case contains a single integer nn (1n21051 \le n \le 2 \cdot 10^{5}).

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (109ai109-10^{9} \le a_i \le 10^{9}).

It is guaranteed that the sum of nn over all test cases does not exceed 21052 \cdot 10^{5}.

Output

For each test case, print a single integer — the maximum score you can get when the game ends.

Sample Input 1

4
4
-4 1 -3 5
4
1 -2 3 -4
3
-1 3 -5
1
-1

Sample Output 1

5
4
2
0

Note

In the first test case, one can get the score of 55 as follows:

  1. In the first turn, choose i=2i=2. Your score remains 00 and the numbers written on the cards from the top will become [4,3,5][-4, -3, 5].
  2. In the second turn, choose i=3i=3. Your score will become 55 and the numbers written on the cards from the top will become [4,3][-4, -3].
  3. In the third turn, end the game with the score of 55.

In the second test case, one can get the score of 44 as follows:

  1. In the first turn, choose i=3i=3. Your score will become 33 and the numbers written on the cards from the top will become [1,2,4][1, -2, -4].
  2. In the second turn, choose i=1i=1. Your score will become 44 and the numbers written on the cards from the top will become [2,4][-2, -4].
  3. In the third turn, end the game with the score of 44.

In the third test case, one can get the score of 22 as follows:

  1. In the first turn, choose i=1i=1. Your score will become 1-1 and the numbers written on the cards from the top will become [3,5][3, -5].
  2. In the second turn, choose i=1i=1. Your score will become 22 and the numbers written on the cards from the top will become [5][-5].
  3. In the third turn, end the game with the score of 22.