#include #include #include #include #include #include #include #include #include #include #define mkp make_pair #define mkt make_tuple #define rep(i,n) for(int i = 0; i < (n); ++i) #define all(v) v.begin(),v.end() using namespace std; typedef long long ll; const ll MOD=1e9+7; template void chmin(T &a,const T &b){if(a>b) a=b;} template void chmax(T &a,const T &b){if(a>N; vector A(N),B(N); rep(i,N) cin>>A[i]; rep(i,N) cin>>B[i]; vector diff(N); rep(i,N) diff[i]=B[i]-A[i]; ll dsum=0; rep(i,N) dsum+=diff[i]; if(N==2){ if(dsum!=0) fail(); else cout<0||abs(dsum)%(N-2)>0){ cout<<-1<0){ ll rest=num-diff[i]; if(rest%2) fail(); sum+=diff[i]+rest/2; }else{ ll rest=num-abs(diff[i]); if(rest%2) fail(); sum+=rest/2; } } if(sum==num) cout<