n = input()
s = map(int, ('+ ' + raw_input()).replace('+ ', '+').replace('- ', '-').split())
s0 = [abs(x) for x in s]
for i in xrange(1, n):
	s0[i] += s0[i - 1]
loc = filter(lambda x: s[x] < 0, xrange(n)) + [n, n]
print max(sum(s), max([s0[n - 1] - (s0[loc[i + 1] - 1] - s0[loc[i] - 1]) * 2 for i in xrange(len(loc) - 1)]))
