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