#!/usr/bin/python3 import fileinput cur = 0 carry = [] for line in fileinput.input(): line = line.rstrip() if line == "": carry.append(cur) cur = 0 continue cur += int(line) carry.append(cur) carry.sort(reverse=True) i = 0 total = 0 for n in carry: print(n) total += n i += 1 if i >= 3: break print("Total: %d" % total)