N = gets.chomp.to_i
A = gets.chomp.split(" ").map(&:to_i)

sum = A.inject(:+)

half = sum / 2.0

r = []
A.each.with_index do |a, i|
  r << A[0..i].inject(:+)
end

if r.include?(half) then
  puts "0"
  exit
end

r.each do |n|
  if n >= half then
    puts (sum - n)
    exit
  end
end