Does not work when all positive input

for eg, if my input is 6,5,4,3,2,1,1 then maximum sum shown is 21 instead of 22 https://ide.codingblocks.com/s/82061