def main(input = STDIN)
  a = (1..30).to_a.inject{|sum, i|sum + i}
  b = (1..30).to_a.inject{|sum, i|sum * i}
  28.times do
    n = input.gets.to_i
    a -= n
    b /= n
  end
  d = ((a ** 2 - 4 * b) ** 0.5).round
  puts (a - d) / 2, (a + d) / 2
end
main