n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) if sum(a) < sum(b): print(-1) else: if n == 2: if sum(a) == sum(b): print(a[0] - b[0]) else: print(-1) elif (sum(a) - sum(b)) % (n - 2) != 0: print(-1) else: c = (sum(a) - sum(b)) // (n - 2) for i in range(n): if abs(a[i] - b[i]) // (n - 2) > c + 1: c = -1 print(c)