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