Simple input challenge

this is the logic for simple input so far i understand
not giving me the output
help ASAP
import java.util.ArrayList;
import java.util.Scanner;

public class SimpleInput {

public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	ArrayList<Integer> list = new ArrayList<>();
	int sum = 0 ;
	
	while(sum>0)
	{
		int n = sc.nextInt();
		sum = sum + n;
		if(sum>0)
		{
			list.add(n);
		}
		else
		{
			for(int i = 0; i<list.size(); i++)
			{
				System.out.println(list.get(i));
			}
		}
	}

}

}

hey @Naman_Gupta
just a change
while(sum>=0) instead of while(sum>0)
and
if(sum>=0)
{
list.add(n);
}
instead of
if(sum>0)
{
list.add(n);
}
and put break Statement inside else
correct code here :