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

def max_i arr
  arr.index(arr.max)
end

a_max = A.max
cnt = 0
while a_max < B.max
  i = max_i B
  i1 = (i + 1) % N
  i2 = (i - 1) % N
  B[i] -= (B[i1] + B[i2])
  cnt += 1
end

if A == B
  puts cnt
  exit
end

puts -1