My program is running and giving the right output in eclipse but showing runtime error in codechef editor while running

‘’'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

please provide link of your solution or paste it properly so that one could read it clearly.
Enclose the quote in ``` in beginning and at the end to increase readability of the code .

Directly submit or put the input in custom input and then check.

actually the run time error is not comming now it got resolved and the program is compiled too but the sub task #1 and #2 are both giving errors please help out