local mfl, mce, mmi = math.floor, math.ceil, math.min
local SegTree = {}
SegTree.updateAll = function(self)
  for i = self.stagenum - 1, 1, -1 do
    for j = 1, self.cnt[i] do
      self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])
    end
  end
end
SegTree.create = function(self, ary, func, emptyvalue)
  self.func, self.emptyvalue = func, emptyvalue
  local stagenum, mul = 1, 1
  self.cnt, self.stage, self.size = {1}, {{}}, {}
  while mul < #ary do
    mul, stagenum = mul * 2, stagenum + 1
    self.cnt[stagenum], self.stage[stagenum] = mul, {}
  end
  for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end
  self.stagenum = stagenum
  for i = 1, #ary do self.stage[stagenum][i] = ary[i] end
  for i = #ary + 1, mul do self.stage[stagenum][i] = emptyvalue end
  self:updateAll()
end
SegTree.getTop = function(self)
  return self.stage[1][1]
end
SegTree.setValue = function(self, idx, value, silent)
  self.stage[self.stagenum][idx] = value
  if not silent then
    for i = self.stagenum - 1, 1, -1 do
      local dst = mce(idx / 2)
      local rem = dst * 4 - 1 - idx
      self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])
      idx = dst
    end
  end
end
SegTree.new = function(ary, func, emptyvalue)
  local obj = {}
  setmetatable(obj, {__index = SegTree})
  obj:create(ary, func, emptyvalue)
  return obj
end

local n = io.read("*n")
local a, b, stb = {}, {}, {}
for i = 1, n do
  a[i] = io.read("*n")
end
for i = 1, n do
  b[i] = io.read("*n")
  stb[i] = {i, b[i]}
end
local st = SegTree.new(stb, function(x, y)
  return x[2] < y[2] and y or x
end, {0, 0})

local rem = n
local cnt = 0
while 0 < rem do
  local top = st:getTop()
  local idx = top[1]
  if b[idx] == a[idx] then
    st:setValue(idx, {idx, 0})
    rem = rem - 1
  else
    cnt = cnt + 1
    local l, r = idx - 1, idx + 1
    if l == 0 then l = n end
    if r == n + 1 then r = 1 end
    if b[l] + b[r] < b[idx] then
      b[idx] = b[idx] - b[l] - b[r]
      st:setValue(idx, {idx, b[idx]})
    else
      cnt = -1
      break
    end
  end
end
print(cnt)
