找出所有 ai<0a_i < 0 的食品累加它们的相反数即可。

#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long n, x, s = 0;
	while (cin >> n)
	{
		s = 0;
		for (int i = 1; i <= n; i++)
		{
			cin >> x;
			if (x < 0) s -= x;
		}
		cout << s << endl;
	}
	return 0;
}