max-sum implemented