Main(function(input) {
	var points = input.trim().split('\n');

	var WPoints = [];
	for (var i = 0; i < 10; i++) {
		WPoints.push(+points[i]);
	}
	WPoints.sort(function (a, b) {
		return b - a;
	});
	var WScore = WPoints[0] + WPoints[1] + WPoints[2];

	var KPoints = [];
	for (var i = 0; i < 10; i++) {
		KPoints.push(+points[i + 10]);
	}
	KPoints.sort(function (a, b) {
		return b - a;
	});
	var KScore = KPoints[0] + KPoints[1] + KPoints[2];
	console.log(WScore, KScore);
});

function Main(callback) {
	var input = '';

	var stdin = process.stdin;

	stdin.resume();
	stdin.setEncoding('utf8');
	stdin.on('data', function(chunk) {
		input += chunk;
	});
	stdin.on('end', function() {
		callback(input);
	});
};