Source Code
#include <stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    int a[n];
    
    for (int i=0; i<n ; i++)
        scanf("%d",&a[i]);
    
    int l=0;
    if (a[0]<1)  l=(-1*a[0])+1;

    int x = l;
    for (int i=0 ; i<n ; i++)
    {
        x+=a[i];
    
        if (x<1)
        {
            l+=(-1*x)+1;
            x=0;
        }
    }
    printf("%d",l);

    return 0;
}
Copy
Zeina The Business Owner misterRoshi22
GNU G++17
2 ms
688 KB
Wrong Answer