import java.io.*;
import java.util.*;
import java.lang.*;
class Codechef {
public static void main(String[] args) throws java.lang.Exception {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-- > 0) {
int dishes = sc.nextInt();
int arr[] = new int[dishes];
for(int i = 0; i < dishes; i++) {
if(sc.hasNextInt()) {
arr[i] = sc.nextInt();
}
}
Arrays.sort(arr);
int a = 0;
int b = 0;
for(int i = dishes - 1; i >= 0; i--) {
if(a >= b) b += arr[i];
else a += arr[i];
}
System.out.println(a > b ? a : b);
}
}
}
I’m getting this error while solving the problem. Where to edit the code to handle this error? Please help.
.