logo AlgoBeat OnlineJudge
登录 注册

#209401. [ICPC 2021 Nanjing R] Windblume Festival

内存限制:256 MiB 时间限制:3000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

The Windblume Festival in Mondstadt is coming! People are preparing windblumes for Barbatos and for those they love and adore. The Windblume Festival is also an opportunity to improve the relationships people have.

During the festival, a famous game will be played every year, invented by Jean, the Acting Grand Master of the Knights of Favonius. In the game, players numbered from to stand in a circle, each holding an integer with them. Each turn, one player will be removed. The game will end when there is only one player left.

For each turn, let be the number of players remaining and be the integer player holds. Two adjacent players, and are selected and player is removed from the game. Player 's integer will then change from to . Player in this turn will become player in the next turn for all , though the integer they hold will not change.

Jean wants to know the maximum possible integer held by the last remaining player in the game by selecting the players in each round optimally.

输入格式

There are multiple test cases. The first line of the input contains one integer indicating the number of test cases. For each test case:

The first line contains one integer () indicating the initial number of players.

The next line contains integers () where is the integer held by player at the beginning.

It is guaranteed that the sum of of all test cases will not exceed .

输出格式

For each test case output one line containing one integer indicating the maximum possible integer.

样例

样例输入 1

5
4
1 -3 2 -4
11
91 66 73 71 32 83 72 79 84 33 93
12
91 66 73 71 32 83 72 79 84 33 33 93
13
91 66 73 71 32 83 72 79 84 33 33 33 93
1
0

样例输出 1

10
713
746
779
0

数据范围与提示

For the first sample test case follow the strategy shown below, where the underlined integers are the integers held by the players selected in each turn.

(select ) (select ) (select ) .