# 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 m == 0
    break
  end

  if B[m_idx] < A[m_idx]
    @ans = -1
    break
  elsif B[m_idx] == A[m_idx]
    B[m_idx] = 0 # いったん 0 にして候補から外したい気持ち
    
    # この更新コストが高い
    m = B.max
    m_idx = B.index{|v| v == m}      

    next
  else # B[m_idx] > A[m_idx]
    diff = B[m_idx] - (B[i(m_idx - 1)] + B[i(m_idx + 1)])
    if diff > 0
      B[m_idx] = diff

      if B[m_idx] < A[m_idx]
        @ans = -1
        break
      end

      # この更新コストが高い
      m = B.max
      m_idx = B.index{|v| v == m}      

      @ans += 1
    else
      @ans = -1
      break
    end
  end
end

puts @ans

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





