N = gets.to_i
arr = gets.split(" ").map(&:to_i)
index = 0
before = 0
after = 0


if N%2 == 0
    (N/2).times do
        before += arr[index]
        index += 1
    end
    (N/2).times do
        after += arr[index]
        index += 1
    end
    puts (before - after).abs
elsif
    (N/2).times do
        before += arr[index]
        index += 1
    end
    
    index += 1
    
    (N/2).times do
        after += arr[index]
        index += 1
    end
    
    if before == after
        puts arr[N/2]
    elsif before > after
        puts (before - (after + arr[N/2])).abs
    else
        puts (after - (before + arr[N/2])).abs
    end
end
