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 d == 0
            if b[0] - b[1] - b[N-1] >= a[0]
                b[0] -= b[1] + b[N-1]
                c += 1
                while b[d] - b[(d+1)] - b[(d-1)] >= a[d]
                    b[d] -= b[(d+1)] + b[(d-1)]
                    c += 1
                    if d < N-2
                        d += 1
                    end
                end
            end
        elsif d == N-1
            if b[N-1] - b[0] - b[N-2] >= a[N-1]
                b[N-1] -= b[0] + b[N-2]
                c += 1
                while b[e] - b[(e+1)] - b[(e-1)] >= a[e]
                    b[e] -= b[(e+1)] + b[(e-1)]
                    c += 1
                    if e > 2
                        e -= 1
                    end
                end
            end
        else
            if b[d] - b[(d+1)] - b[(d-1)] >= a[d]
                b[d] -= b[(d+1)] + b[(d-1)]
                c += 1
                e = d-1
                if e == 0
                    e += 1
                end
                while b[e] - b[(e+1)] - b[(e-1)] >= a[e]
                    b[e] -= b[(e+1)] + b[(e-1)]
                    c += 1
                    if e > 2
                        e -= 1
                    end
                end
                while b[d] - b[(d+1)] - b[(d-1)] >= a[d]
                    b[d] -= b[(d+1)] + b[(d-1)]
                    c += 1
                    if d < N-2
                        d += 1
                    end
                end
            end 
        end
        d += 1
    end
end

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

puts answer