#P1978A. Alice and Books

    ID: 10698 Type: RemoteJudge 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 3 Uploaded By: Tags>constructive algorithmsgreedysortings*800

Alice and Books

Description

Alice has nn books. The 11-st book contains a1a_1 pages, the 22-nd book contains a2a_2 pages, \ldots, the nn-th book contains ana_n pages. Alice does the following:

  • She divides all the books into two non-empty piles. Thus, each book ends up in exactly one of the two piles.
  • Alice reads one book with the highest number in each pile.

Alice loves reading very much. Help her find the maximum total number of pages she can read by dividing the books into two piles.

Each test consists of multiple test cases. The first line contains a single integer tt (1t5001 \le t \le 500) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer nn (2n1002 \le n \le 100) — the number of books Alice has.

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1ai1091 \le a_i \le 10^9) — the number of pages in each book.

For each test case, output a single integer — the maximum number of pages Alice can read.

Input

Each test consists of multiple test cases. The first line contains a single integer tt (1t5001 \le t \le 500) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer nn (2n1002 \le n \le 100) — the number of books Alice has.

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1ai1091 \le a_i \le 10^9) — the number of pages in each book.

Output

For each test case, output a single integer — the maximum number of pages Alice can read.

Sample Input 1

5
2
1 1
4
2 3 3 1
5
2 2 3 2 2
2
10 3
3
1 2 3

Sample Output 1

2
4
5
13
5

Note

In the first test case, Alice can put book number 11 in the first pile, and book number 22 in the second pile. Then she will read a1+a2=1+1=2a_1 + a_2 = 1 + 1 = 2 pages.

In the second test case, Alice can put books with numbers 22 and 33 in the first pile, and books with numbers 11 and 44 in the second pile. Then she will read the book with the highest number 33 from the first pile, and the book with the highest number 44 from the second pile. Then she will read a3+a4=3+1=4a_3 + a_4 = 3 + 1 = 4 pages.