Source Code
/*#include <iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		if ()
	}
}
*/
#include <iostream>

using namespace std;

int main() {
	int com[100001];
	com[0] = 0;
	int n; cin >> n;
	int tmp, ans = 0;
	for (int i = 1; i <= n; i++) {
		cin >> tmp;
		com[i] = com[i - 1] + tmp;
		if (com[i] < 0 && tmp < 0)
			ans += com[i];
	}
	cout << abs(ans);

	system("pause");

	return 0;
}
Copy
Zeina The Business Owner psutMoha
GNU G++17
4 ms
1.3 MB
Wrong Answer