l=[4,6,10,8,2,1] ans=0 m=3 for i in range(len(l)+1): for j in range(i): if len(l[j:i])==m: ans=max(ans,sum(l[j:i])) print(ans)