# constant

MAX_INT = 1 << 31

### main

n = gets.strip.to_i

as = []
ps = [MAX_INT, MAX_INT, MAX_INT]

n.times do
  ai = gets.strip

  for aj in as
    for pi in [(ai + aj).to_i, (aj + ai).to_i]
      ps << pi
      ps.sort!
      ps.pop
    end
  end

  as << ai
end
puts ps[2]