n = [2,-3,-4,4,-5,6] sum_list = [] for i in range(len(n)): for j in range(len(n)): if j<i: continue else: x = sum(n[i:j+1]) sum_list.append(x) print(max(sum_list))