/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int minX(vector<int> &arr)
{
vector<int> temp;
int sumwX = 1;
for(auto it = arr.begin(); it != arr.end(); ++it)
{
sumwX += *it;
temp.push_back(sumwX);
}
return (1 - (*min_element(temp.begin(), temp.end()) - 1 ));
}
int main()
{
vector<int> M = {-5,4,-2,3,29,-1,-6,-1,0,-5};
vector<int> N = {-2,3,1,-5};
vector<int> V = {-5,4,-2,3,1,-1,-6,-1,0,-5};
cout << minX(M) << endl;
cout << minX(N) << endl;
cout << minX(V) << endl;
return 0;
}