First & Last (Contest)
First & Last (Contest) easy Time Limit: 2 sec Memory Limit: 128000 kB
Last updated
First & Last (Contest) easy Time Limit: 2 sec Memory Limit: 128000 kB
Last updated
Problem Statement :
Ram is given an array A of length N, Ram can right-rotate the array any number of times (possibly zero times also). His task is to find out the maximum value of A1 + AN. Note: Right rotation of array [A1, A2,. , AN] is [AN, A1,. , AN-1]. Input The first line of the input contains a single integer T, denoting the number of test cases. The first line of each test case contains a single integer N, denoting the size of an array A. The second line of each test case contains N space- separated integers denoting array A.
Constraints 1 ≤ T ≤ 1000 1 ≤ N ≤ 105 1 ≤ Ai ≤ 109 Output For each test case output on a new line denoting the maximum value of A1 + AN. Example Sample Input 3 2 5 8 3 5 10 15 4 4 4 4 4 Sample Output 13 25 8
link: