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 <= 0){

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

	}

	cout << lend;
	return 0;
}
Copy
Zeina The Business Owner safareto
GNU G++17
2 ms
620 KB
Wrong Answer