Test case problem

i am not understanding the problem in my code but test cases failed for some inputs message is showing why ?
this is my code:

#include
using namespace std;
int main() {
int n;
cin>>n;
int i=1,sum=0;
while(i<=n)
{
int no;
cin>>no;
sum=sum+no;
if(sum<0)
break;
cout<<no<<endl;
i++;
}

return 0;

}

The approach you are using is not correct …
You need to use while loop in your code as,
while(sum>=0)
{
cin>>n;
sum=sum+n;
if(sum>=0)
{
cout<<n;
cout<<endl;
}
else
if(sum<0)
return 0;
}