So I have been trying to solve a problem
Here is the code.
import java.util.Arrays;
import java.util.Scanner;
class Salary {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int T = in.nextInt();
int arr[];
while(T-->0){
int N = in.nextInt();
int steps = 0;
arr = new int[N];
for(int i=0;i<N;i++){
arr[i] = in.nextInt();
}
Arrays.sort(arr);
int indexL = N -1 ;
for(int i =0 ;i<arr.length-1;i++){
steps+= arr[indexL]- arr[i];
}
System.out.println(steps);
}
in.close();
}
}
Can anybody point the error in this code?