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

def get_is i
  [(i + 1) % N, i, (i - 1) % N]
end

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

b_min = B.min
cnt = 0
while A.max <= B.max
  if A == B
    puts cnt
    exit
  end
  i1, i, i2 = get_is(max_i B)
  B[i] -= (B[i1] + B[i2])
  cnt += 1
end

puts -1