N = gets.chomp.to_i
str = gets.split
a = Array.new(N)
for i in 0...N do
    a[i] = str[i].to_i
end
str = gets.split
b = Array.new(N)
for i in 0...N do
    b[i] = str[i].to_i
end

answer = -1
c = 0
d = 0

while c != answer
    answer = c
    if b[0] - b[1] - b[N-1] >= a[0]
        b[0] -= b[1] + b[N-1]
        c += 1
    end
    d = 1
    while d < N-1
        if b[d] - b[d-1] - b[d+1] >= a[d]
            b[d] -= b[d-1] + b[d+1]
            c += 1
        end
        d += 1
    end
    if b[N-1] - b[0] - b[N-2] >= a[N-1]
        b[N-1] -= b[0] + b[N-2]
        c += 1
    end
end

for i in 0...N do
    if a[i] != b[i]
        puts "-1"
        exit
    end
end

puts answer