Regarding greater sum

Sir my one test case is failed saying no output

/******************************************************************************

                        Online Java Compiler.
            Code, Compile, Run and Debug java program online.

Write your code in this editor and press “Run” button to execute it.

******************************************************************************/
import java.util.
;
public class Main
{

public static void main(String[] args) {
    Scanner s=new Scanner(System.in);
	
    int N=s.nextInt();
     Stack<Integer> st=new Stack<>();
    int arr[]=new int[N];
	if(arr.length==1){
		System.out.println("-1");
	}
    for(int i=0;i<N;i++){
        arr[i]=s.nextInt();
    }
    
    

    for(int j=1;j<arr.length;j++){
    st.push(arr[0]);
       while(!st.empty() && st.peek()<arr[j]){
           
           System.out.print(arr[j]+" ");
           st.pop();
       }
      
       
       
    
    



    }
     if(st.empty()){
           System.out.print("-1");
       }
}

}

Hi Saurabh,
Your code won’t give any output if all the elements are same.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.