Optimal game strategy

Hey one of my test case (test case 0) is not working can you please check what might be the error here

Hey @bhavik911
Try for this input
26
2396 25316 30085 23080 10269 5711 8306 11536 19092 6816 6305 23649 32583 5585 14193 14859 30265 18026 5528 16126 15212 25591 14789 3900 31395 25529
correct output : 224098

What might be the bug here in the code , I dont really know what i have done wrong

package Recursion;

import java.util.Scanner;

public class kk {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] arr = new int[N];
        for (int i = 0; i < N; i++) {
            arr[i] = scanner.nextInt();
        }
        System.out.println(optimal(arr,0,arr.length-1,0));

    }
    public static int optimal(int[] arr,int lo , int high, int sum){
        if(lo>high){
            return sum;
        }

        int sum1;
        int sum2;
        int sum3;
        int sum4;
        int sum5;
        int sum6;
            sum1 = sum + arr[high];
            sum2  = optimal(arr, lo+1,high-1,sum1);
            sum3 = optimal(arr, lo,high-2,sum1);

            sum4 = sum + arr[lo];
            sum5  = optimal(arr, lo+1,high-1,sum4);
            sum6 = optimal(arr, lo+2,high,sum4);


        return Math.max(Math.min(sum2,sum3) , Math.min(sum5,sum6));
    }
}

I am getting right for every test case now, but does this seems like an efficient one?
I have to create 6 variables here

@bhavik911
Code is fine
Create 6 variables here // No issue

\Okay , can you please look at rest of my doubts posted them yesterday related to mcq

@bhavik911
okay I see it
Please mark your doubts as resolved in your course’s.