## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

## [Solution] First and Last CodeChef Solution | CodeChef Problem Solution 2022

You are given an array $A=\left[{A}_{1},{A}_{2},\dots ,{A}_{N}\right]$ of length $N$.

You can right rotate it any number of times (possibly, zero). What is the maximum value of ${A}_{1}+{A}_{N}$ you can get?

Note: Right rotating the array $\left[{A}_{1},{A}_{2},\dots ,{A}_{N}\right]$ once gives the array $\left[{A}_{N},{A}_{1},{A}_{2},\dots ,{A}_{N-1}\right]$. For

example, right rotating $\left[1,2,3\right]$ once gives $\left[3,1,2\right]$, and right rotating it again gives $\left[2,3,1\right]$.

### Input Format

• The first line of input will contain a single integer $T$, denoting the number of test cases. The description of the test cases follows.

• The first line of each test case contains a single integer $N$, denoting the length of array $A$.
• The second line of each test case contains $N$ space-separated integers ${A}_{1},{A}_{2},\dots ,{A}_{N}$ — denoting the array $A$.

### Output Format

For each test case, output on a new line the maximum value of ${A}_{1}+{A}_{N}$ you can get after several right rotations.

### Constraints

• $1\le T\le 1000$
• $2\le N\le {10}^{5}$
• $1\le {A}_{i}\le {10}^{9}$
• The sum of $N$ across all test cases does not exceed