#include #define rep(i,n) for(int i=0;i<(int)(n);i++) using namespace std; using ll = long long ; using P = pair ; using pll = pair; constexpr int INF = 1e9; constexpr long long LINF = 1e17; constexpr int MOD = 1000000007; constexpr double PI = 3.14159265358979323846; int main(){ int n; cin >> n; vector a(n),b(n); rep(i,n) cin >> a[i]; rep(i,n) cin >> b[i]; ll suma = 0, sumb = 0; rep(i,n) suma += a[i]; rep(i,n) sumb += b[i]; if(n==2){ if(suma==sumb){ cout << abs(a[0]-b[0]) << endl; }else{ cout << -1 << endl; } return 0; } if((suma-sumb)%(n-2)!=0||suma