Doubt regarding Simple input

not sure where program went wrong
according to 2nd test case inputs provided are
//1
// -2
//-88
//-42
//-100
and output is 1
got the same output still program is compiling with 2nd test case as wrong

package challenges;

import java.util.Scanner;

public class SimpleInput {

public static void main(String[] args) {
	//Print all the numbers before the cumulative sum become negative.

int[] a=new int[1000];
int sum=0;
int las=0;
Scanner s=new Scanner(System.in);

	for(int i=0;i<a.length;i++)
		
	{
		if(a[i]>-1000&&a[i]<1000) {
		 a[i]=s.nextInt();
		}
		 sum=sum+a[i];
		 if(sum<0) {
			 
			 las  = i;
		 
		 
			 break;
		 
		 
		 
		 }
		 
		 
		 
	
	}

	for(int i=0;i<las;i++)
	{
		if( a[i]!=0)
		
	
			 
		System.out.println(a[i]);
			 
	

			
			 
		}
	}


}

Hi @Pradeep,
Actually you have not considered the case if some of the input are 0 . For example if the input are 0 0 0 1 -2 then you should display 0 0 0 1 but your code will display only 1. So this is the bug.