n = gets.to_i
arr = []
n.times{arr << gets.to_i}
result = []
for i in 0...n
    for j in 0...n
        next if i == j
        result << ((arr[i].to_s + arr[j].to_s).to_i)
    end
    result.sort!
    result = result[0..2]
end
puts result.last
