This Java code is not working when I give input more than 8(infinite loop)

import java.lang.;
import java.util.
;
import java.io.*;
public class Main {
public static void main(String args[]) throws Exception{
BufferedReader buff =new BufferedReader(new InputStreamReader(System.in));
int t=Integer.parseInt(buff.readLine());
while(t!=0)
{
int n=Integer.parseInt(buff.readLine());
int a[]=new int[n];
String s[]=buff.readLine().split(" “);
for(int i=0;i<n;i++)
{
a[i]=Integer.parseInt(s[i]);
}
int move=1,alice=a[0],bob=0;
int i=1,j=n-1;
while(i<=j)
{
if(move%2!=0)
{
while(bob<alice && i<=j)
{
bob+=a[j];
j–;
}
System.out.println(bob);
}
else
{
while(alice<bob && i<=j)
{
alice+=a[i];
i++;
System.out.println(alice);
}
}
move++;
}
System.out.println(move+” “+alice+” "+bob);
t–;
}
}
}