You, the great businessman of TEUB, arrived at ESC land which consists of cities numbered from 1 to . You are currently at city 1. For each city , you arrive at (including your current city) in ESC land, you do some business and make profit . The profit can be negative which means you have lost amount of money in your business.But there is a special rule for travelling ESC land:
First you can go from your current location i.e. city 1 to city through the path ( ).
Then you can go from city to city through the path ( ).
So, your profit will be
Note that you may stay at city 1 and you may also choose not to go to reverse direction (i.e. direction to which city index decreases).
Find out maximum profit you can achieve.
First line will be number of test cases
For each test case:
In the first line, the number of cities will be given.
Then there will be integers where denotes achievable profit from city at a time.
Constraints
Over all test cases,
For each test case, print one line containing maximum possible profit you can gain.
Input | Output |
---|---|
4 1 4 2 4 -2 3 5 2 -10 4 -1 3 -2 4 | 4 6 12 5 |
Optimal paths for the 4 testcases are:
path: , profit:
path: , profit:
path: , profit:
path: , profit: