# require 'pry'

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

# print B

def i(i)
  i % N
end

m = B.max
m_idx = B.index{|v| v == m}

@ans = 0
while (true)
  if (A[m_idx] < B[m_idx])
    diff = (m - (B[i(m_idx - 1)] + B[i(m_idx + 1)])) 
    if diff > 0
      B[m_idx] = diff
      m = B.max
      m_idx = B.index{|v| v == m}      
      @ans += 1
    else
      @ans = -1
      break
    end
  else
    break
  end
end

if B == A
  puts @ans
else
  puts -1
end
# binding.pry