#!/usr/local/bin/ruby
rec=Array.new
a=0
while (line=gets)!=0
   n=line.to_i
   n.times{
      rec << gets.to_i
   }
   for i in 0..(n-1)
      a = a + rec[i].to_i
   end
   (n-1).downto(0){|i|
      if a - rec[i].to_i > a
         a = a - rec[i].to_i
      end
   }
puts "#{a}"
end