#!/usr/bin/ruby
# -*- coding: utf-8 -*-

w = []
10.times do
  w.push gets.to_i
end
y = []
10.times do
  y.push gets.to_i
end

w.sort!
y.sort!

printf "%d %d\n", w[9] + w[8] + w[7], y[9] + y[8] + y[7]
                 