How to correct code

I wrote this code for Challenges - Recursion
Topic :- Subset Sum Easy
import java.util.Scanner;
public class Main {
public static boolean sum(int[] arr){
if(arr.length==0){
return false;
}
int a = arr[0];
int[] subarray = new int[arr.length-1];
int s=0;
for(int i=1;i<arr.length;i++){
subarray[i-1]=arr[i];
s+=subarray[i-1];
}
boolean flag = sum(subarray);
for(int i=0;i<subarray.length;i++){
if(s==0){
if(subarray.length!=0){
flag=true;
}
}else if(subarray[i]+a==0){
flag = true;
}else if(a==0){
flag = true;
}
}
return flag;
}
public static void main(String args[]) {
Scanner scn = new Scanner(System.in);
int t = scn.nextInt();
int row=1;
while(row<=t){
int n = scn.nextInt();
int[] arr = new int[n];
for(int i=0;i<n;i++)
arr[i] = scn.nextInt();
if(sum(arr)){
System.out.println(“Yes”);
}else{
System.out.println(“No”);
}
row++;
}
}
}

Some of the test cases are coming wrong please tell me how to improve this code to perfect all test cases.

@sanchit02,
Sample test case:
1
4
2 2 3 -7
Correct Answer:
Yes
Your Answer:
No

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.