‘’'import java.util.;
import java.lang.;
import java.io.*;
class codechef
{
public static void main(String args[]) throws java.lang.Exception
{
int profit=0;int temp;
Scanner sc=new Scanner(System.in);
if(sc.hasNext()){
int T = sc.nextInt();
for(int i=0;i<T;i++)
{
int N=sc.nextInt();
Integer[] arr=new Integer[N];
for(int j=0;j<N;j++)
{
arr[j]=sc.nextInt();
}
Arrays.sort(arr, Collections.reverseOrder());
outerloop: for(int k=0;k<N;k++)
{
temp=0;
temp=arr[k];
if(temp==0)
{
break outerloop;
}
else if(temp!=0) {
profit+=temp;
for(int u=k+1;u<N;u++)
{
arr[u]=arr[u]-1;
}
}
}
System.out.println(profit%1000007);
}
}
}
}
question : CARSELL Problem - CodeChef