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
e = 0

while c != answer
    answer = c
    d = 0
    while d < N
        if b[d%N] - b[(d+1)%N] - b[(d-1)%N] >= a[d%N]
            b[d%N] -= b[(d+1)%N] + b[(d-1)%N]
            c += 1
            e = d-1
            while b[e%N] - b[(e+1)%N] - b[(e-1)%N] >= a[e%N]
                b[e%N] -= b[(e+1)%N] + b[(e-1)%N]
                c += 1
                e -= 1
            end
            while b[d%N] - b[(d+1)%N] - b[(d-1)%N] >= a[d%N]
                b[d%N] -= b[(d+1)%N] + b[(d-1)%N]
                c += 1
                d += 1
            end
        end
        d += 1
    end
end

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

puts answer