You are given an array of size and queries. For each query, you are given two indices of the array and . The subarray generated from to is reversed. Your task is to determine the maximum sum of the subarrays.
Note: After each query is solved, the array comes to its initial states.
Input format
Output format
For each query, print the required answer in a new line.
Constraints
Given array is {3,-1,4,2,-1}.
For first query L=3 and R=4. Now the array becomes {3,-1,2,4,-1}.
Maximum sub-array sum is 8 and the sub-array is {3,-1,2,4}.
For second query L=1 and R=2. Now the array becomes {-1,3,4,2,-1}.
Maximum sub-array sum is 9 and the sub-array is {3,4,2}.