Simple Input Question

Sir below is my code to Simple Input Question.
Can you please tell me where I am going wrong.

#include
using namespace std;
int main()
{
int sum = 0;
int i = 0;
int arr[2000];
while(sum>=0)
{
int n;
cin>>n;
sum+=n;
if(sum<0)
{
break;
}
else{
arr[i] = n;
i++;
}
}

for(int m=0;m<i;m++)
{
cout<<arr[m]<<endl;
}
return 0;
}

Hey, your code is correct and its passing all the cases.

ok thank you sir…

Is there any way to solve without using array?