def maxSubarray(x):
	"""Returns (a, b, c) such that sum(x[a:b]) = c and c is maximized.
	See https://en.wikipedia.org/wiki/Maximum_subarray_problem"""
	cur, best = 0, 0
	curi = starti = besti = 0
	for ind, i in enumerate(x):
		if cur + i > 0:
			cur += i
		else: # reset start position
			cur, curi = 0, ind + 1

		if cur > best:
			starti, besti, best = curi, ind + 1, cur
	return starti, besti, best