Optimal game strategy 1 problem

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner cin = new Scanner(System.in);
int n = cin.nextInt(), arr[] = new int[n];
for(int i = 0 ;i<arr.length;i++){
arr[i] = cin.nextInt();
}
printMax(arr,0,arr.length-1);
}
public static void printMax(int []arr,int p,int ei){
if(ei <0){
System.out.println§;
return;
}
printMax(arr,p+arr[ei],ei-2);
}
}=======what’s the error in my code please make corrections

@AbhishekAhlawat1102 please paste your code on ide and then share it instead of the raw code.
what is the symbol § you have used ith your print ln??

https://ide.geeksforgeeks.org/gbtKIfHOS5

@AbhishekAhlawat1102 you can use ide.codingblocks.com too.
for your code you have assumed that it is srited array .but it is not so we d have to see the max out of front and end and add that.

Can i sort it in advance wil it then give correct output

@AbhishekAhlawat1102 no the contestents get to pick from the given order .if u sort it your answer will be wrong