n=int(input())
table=[int(x) for x in input().split(" ")]
exc=0
m=0
print(table)
for i in table:
if exc >0:
exc=exc+i
else:
exc=i
if m<exc:
m=exc
table=[int(x) for x in input().split(" ")]
exc=0
m=0
print(table)
for i in table:
if exc >0:
exc=exc+i
else:
exc=i
if m<exc:
m=exc
print(m)
当然,最小字段和只需将exc>0 变为exc<0即可