Could someone please tell me what is wrong with this code? It shows wrong answer for some test cases, and is there any way to see what input failed?

thanks.

import java.util.*;

public class smartphonezco{

public static void main(String args[]) {

Scanner obj = new Scanner(System.in);

int i,n,max;

System.out.println("enter total number of customers: ");

n = obj.nextInt();

int b[] = new int [n];

int sum[] = new int[n];

for ( i=0;i<n;i++)

{

b[i] = obj.nextInt();

}

Arrays.sort(b);

for ( i =0;i<n;i++)

{

sum[i] = b[i] * (n-i);

}

max = sum[0];

for (i=1;i<n;i++)

{

if (sum[i] >max)

max = sum[i];

}

System.out.println(max);

}

}