Source Code
#include <iostream>
using namespace std;
const int N = 1e5 + 5;
int main() {
	int n, a[N],lend=0,profit=0;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	for (int i = 0; i < n; i++) {
		profit += a[i];
		if (profit < 1 ){

			lend += (-1 * profit) + 1;
			profit += (-1 * profit) + 1;
		}


	}

	cout << lend;
	return 0;
}
Copy
Zeina The Business Owner safareto
GNU G++17
23 ms
1.3 MB
Accepted