a=gets.chomp.to_i
b=gets.chomp.split.map(&:to_i)

hash={}
array=[]
a.times do |i|
  hash[i] = b[i]
  array << i
end

def logic(args,k, hash)
  dp = args
  y = (hash[k[0]] + hash[k[1]]) / 2
  dp.delete(k[0])
  dp.delete(k[1])
  return y,dp
end

def logic2(args, y, hash)
  dp = args
  dp2 = []

  dp2.push(dp[0])
  dp2.push(dp[1])
  y = (hash[dp2[0]] + hash[dp2[1]]) / 2
  dp.delete(dp2[0])
  dp.delete(dp2[1])
  return y, dp
end

z = array.combination(2).to_a
x = []
z.each_with_index do |k,i|
  dp = array.dup
  y,dp = logic(dp,k,hash)
  if dp.size > 1
    while dp.size != 1 do
      y,dp = logic2(dp,y,hash)
    end
    tmp = dp[0]
    x << (y.to_i + hash[tmp].to_i) / 2
  else
    tmp = dp[0]
    x << (y.to_i + hash[tmp].to_i) / 2
  end
end

p x.max