N = int(input()) A = tuple(map(int, input().split())) B = tuple(map(int, input().split())) def is_impossible(b): if b: print(-1) exit() if N == 2: print(abs(A[0] - B[0]) if sum(A) == sum(B) else -1) exit() is_impossible((sum(A) - sum(B)) % (N - 2)) x = (sum(A) - sum(B)) // (N - 2) is_impossible(x < 0) is_impossible(any(B[i] < A[i] - x for i in range(N))) print(x)