var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n").map(Number);
var a=[];
var b=[];
Arr.forEach(function(v,i){
if(i<10)a.push(v);
if(i>=10)b.push(v);
});
a.sort(function(a,b){return b-a;});
b.sort(function(a,b){return b-a;});
console.log((a[0]+a[1]+a[2])+" "+(b[0]+b[1]+b[2]));