what's wrong with this code of "Salary" problem?

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

/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{

	Scanner s=new Scanner(System.in);
	int t=s.nextInt();
	for(int i=0;i<t;i++)
	{int n=s.nextInt();
	int a[]=new int[n];
	for(int j=0;j<n;j++)
	a[j]=s.nextInt();
	int count=0;
	Arrays.sort(a);
	for(int j=0;j<n-1;j++)
	{count+=a[n-1]-a[j];}
	System.out.println(count);
}

}}

If the input is:

1
1 1 3  

Your code will produce an output of 4, while the optimal solution for this is 2 (Fixing the third number, then increasing the first two numbers 2 times).

You can look at its editorial to understand how to solve this problem.
Hope this helped :slight_smile: