num=int(input())
a=list(map(int,input().split()))
b=list(map(lambda x :[int(x),1],input().split()))
flag=False
for aele ,bele in zip(a,b):
    if aele==bele[0]:
        bele[1]=0
    elif aele >bele[0]:
        flag=True
        break
if flag:
    print(-1)
else:
    count=0
    while not flag:
        mx=max(b,key=lambda x:x[0]*x[1])
        if mx[1]==0:
            flag=True
            break
        m=b.index(mx)
        count+=1
        if m==0 :
            b[0][0]-=b[1][0]+b[num-1][0]
        elif m==num-1:
            b[m][0]-=b[m-1][0]+b[0][0]
        else:
            b[m][0]-=b[m-1][0]+b[m+1][0]
        if b[m][0]==a[m]:
            b[m][1]=0
        elif b[m][0]<a[m]:
            break
    if flag:
        print(count)
    else:
        print(-1)