 Max sum subarray by removing at most one element
##### Submissions: 5108   Accuracy: 25.18%   Difficulty: Medium   Marks: 4

You are given array A of size n. You need to find the maximum-sum sub-array with the condition that you are allowed to skip at most one element.

Input Format:
The first line of input contains an integer T denoting the number of test cases. The description of T test cases follows. The first line of each test case contains a single integer n denoting the size of array. The second line contains n space-separated integers A1, A2, ..., An denoting the elements of the array.

Output Format:
For each test case, in a new line, print the maximum sum.

This is a function problem. The driver code takes input. Your task is to complete the function maxSumSubarray that take array and size as parameters and returns the maximum sum.

Constraints:
1 <= T <= 100
1 <= n <= 100
-103 <= Ai<= 103

Example:
Input:

2
5
1 2 3 -4 5
8
-2 -3 4 -1 -2 1 5 -3

Output:
11
9

Explanation:
Testcase1:

Input  : A[] = {1, 2, 3, -4, 5}
Output : 11
We can get maximum sum subarray by skipping -4.
Testcase2:
Input  : A[] = [-2, -3, 4, -1, -2, 1, 5, -3]
Output : 9
We can get maximum sum subarray by skipping -2 as [4, -1, 1, 5] sums to 9, which is  the maximum achievable sum.

#### ** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Harshit Sidhwa
Author: Shubham Joshi 1

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.