N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) if N == 2: if A[0] - B[0] == -(A[1] - B[1]): print(abs(A[0] - B[0])) else: print(-1) elif N > 3: print(1/0) if (sum(A) - sum(B)) % (N - 2) == 0: print((sum(A) - sum(B)) // (N - 2)) else: print(-1)