It works but it doesn't pass testing. I've tested it before verify and it's adding as well as adding in -1 before closing.
package com.codegym.task.task04.task0442;
/*
Adding
*/
import java.io.*;
public class Solution {
public static int sum = 0;
public static void main(String[] args) throws Exception {
//write your code here
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
while(true) {
int num = 0;
String n = reader.readLine();
num = Integer.parseInt(n);
sum = sum + num;
System.out.println(sum);
if(num == -1) {
break;
}
}
}
}