Getting error in below code i commented over my line where error is occuring

import java.util.;
import java.lang.
;
import java.io.*;

public class CC{

    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);

    //int t = sc.nextInt();
    int t = 1;

    while(t-->0){

       int n = 5,p = 4,z = 1;

       int arr[] ={1,5,4,3,2};

       int ans = arr[0];

       System.out.println(solve(arr,n,p,z,1,ans));

   }

}   

public static int solve(int[] arr, int n , int p,int z,int i,int ans){

   if(i==n || p == 0) return ans;     
    
    if(z>0)
    int a = solve(arr,n,p--,z--,i-1,ans+=arr[i-1]); // error here is variable declaration is not allowed here ;
    int b = solve(arr,n,p--,z,i+1,ans+=arr[i+1]);


    int m = Math.max(a,b);

    return m;

}

}

please share the question