import numpy as np N = int(input()) A = np.array(input().split(), dtype=np.int64) B = np.array(input().split(), dtype=np.int64) ans = -1 v = (A.sum() - B.sum()) / (N - 2) if ((B - A + v) % 2 == 0).all() and ((B - A + v) / 2).sum() == v: ans = int(v) print(ans)