Why am i getting wrong ans for my this code
import java.io.*;
import java.util.*;
class CHEFRP
{
public static void main(String[] args)throws IOException{
int TESTCASES;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
TESTCASES=Integer.parseInt(br.readLine());
int b=2*TESTCASES,i=0,m,l;
int a;
String[] lines=new String[b];
int[] N=new int[TESTCASES];
for(a=0;a<b;a++)
{
lines[a]=br.readLine();
}
int[][] Ai =new int[TESTCASES][100001];
for(a=0;a<b;a=a+2)
{
N[a/2]=Integer.parseInt(lines[a]);
}
for(a=1;a<b;a=a+2)
{
StringTokenizer stz=new StringTokenizer(lines[a]);
for(l=0;l<100001;l++)
{
if(stz.countTokens()!=0)
{
Ai[((a-1)/2)][l]=Integer.parseInt(stz.nextToken());
}
else{
break;
}
}
}
int[] min=new int[TESTCASES];
for(a=0;a<TESTCASES;a++)
{
min[a]=Ai[a][0];
for(l=0;l<N[a];l++)
{
if(min[a]>Ai[a][l])
{
min[a]=Ai[a][l];
}
}
}
int[] sum=new int[TESTCASES];
for(a=0;a<TESTCASES;a++)
{
for (l=0;l<N[a];l++)
{
sum[a]=sum[a]+Ai[a][l];
}
sum[a]=sum[a]+2-min[a];
}
int flag=0,minusonecase=-1;
for(a=0;a<TESTCASES;a++)
{
for(l=0;l<N[a];l++)
{
if(Ai[a][l]==1)
{
System.out.println(minusonecase);
flag=1;
break;
}
}
if(flag==1)
{
continue;
}
System.out.println(sum[a]);
}
}
}