My issue
what is the error in my code
My code
import java.util.*;
import java.lang.*;
import java.io.*;
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int n=sc.nextInt();
int ar[]=new int[n];
for(int i=0;i<n;i++){
ar[i]=sc.nextInt();
}
boolean sorted=true;
for(int i=1;i<n;i++){
if(ar[i]<ar[i-1]){
sorted=false;
break;
}
}
if(sorted){
System.out.println("0");
continue;
}
int k=0;
for(int i=1;i<n;i++){
if(ar[i]<ar[i-1]){
k=Math.max(k,ar[i]+ar[i-1]);
}
}
System.out.println(k);
}
}
}
Problem Link: Another Game Practice Coding Problem