Query against the Challenge (simple Input)

The following input by the user we have to store somewhere to print the output one by one , i can’t find a way apart from Collections to store the inputs, please guide me.

No need to store the inputs
just take input continuously in a while loop while checking the condition of sum as mentioned in the question