Help me in solving ONEFROMK problem - Starters 99

Starters 99 - Exclusion-Inclusion; why the code is showing wrong while submitting?


public static void main (String[] args) throws java.lang.Exception
{
	Scanner sc = new Scanner(System.in);
	int T = sc.nextInt();
	for(int i = 0; i < T; i++){
	    int N = sc.nextInt();
	    int arr[] = new int[N];
	    for(int j = 0; j < N; j++){
	        arr[j] = sc.nextInt();
	    }
	    
	    Arrays.sort(arr);
	   
	    int sum = 0;
	    for(int j = 0; j < N; j++){
	        sum = sum + arr[j];
	    }
	    
	    for(int j = 0; j < N; j++){
	        System.out.print(sum + " ");
	        sum = sum - arr[j];
	    }
	    System.out.println();
    }
}

@ayanbhunia2002
use long long int because of the constraints