For this Question: 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.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.

Constraints:
1 <= T <= 10
1 <= n <= 10^5
-10^3 <= Ai<= 10^3For each test case, in a new line, print the maximum sum.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., I have written this Solution Code: import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	public static void main(String[] args)throws IOException
	{
    //     Scanner sc = new Scanner(System.in);
    // 	int t = sc.nextInt();
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(read.readLine());
    	while(t-->0)
    	{
    		int n = Integer.parseInt(read.readLine());
    		int[] a = new int[n];
    		String str[] = read.readLine().trim().split(" ");
    		for(int i = 0;i < n; i++)
    			a[i] = Integer.parseInt(str[i]);
    		NS g = new NS();
    		System.out.println(g.maxSumSubarray(a , n));
    	}
	}
}
class NS
{
public static int maxSumSubarray(int A[], int n)
{
    int[] fw=new int[n];    // 2 pointer approach, L[i] and R[i] will store Left and Right max sum at ith pos. 
	int[] bw=new int[n];
    int cur_max = A[0], max_so_far = A[0];
    fw[0] = cur_max;
    for (int i = 1; i < n; i++)
    {
        cur_max = Math.max(A[i], cur_max + A[i]);   // either adding previous best ans to the new element makes it max or current element is max
        max_so_far = Math.max(max_so_far, cur_max);
        fw[i] = cur_max;
    }
    cur_max = max_so_far = bw[n-1] = A[n-1];
    for (int i = n-2; i >= 0; i--)
    {
        cur_max = Math.max(A[i], cur_max + A[i]);   // either adding previous best ans to the new element makes it max or current element is max
        max_so_far = Math.max(max_so_far, cur_max);
        bw[i] = cur_max;
    }
    int fans = max_so_far;
    for (int i = 1; i < n - 1; i++)
        fans = Math.max(fans, fw[i - 1] + bw[i + 1]);   // Skipping the ith value and getting the best answer from L[i-1] and R[i+1]
 
    return fans;
}
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?