data = []
20.times do
  data << $stdin.gets.to_i
end

scoreW = data[0..9].sort!{|p,q| q <=> p}[0..2].inject(:+)
scoreK = data[10..19].sort!{|p,q| q <=> p}[0..2].inject(:+)

printf "%d %d\n", scoreW, scoreK