n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) if n==2: if sum(a)!=sum(b):exit(print(-1)) else:exit(print(abs(a[0]-b[0]))) if sum(a)