#include<bits/stdc++.h>

using namespace std;

#define int long long

signed main(){

int t;

cin>>t;

while(t–){

int n;

cin>>n;

int arrA[n],arrB[n-1];

for(int i=0;i<n;i++)cin>>arrA[i];

for(int i=0;i<n-1;i++)cin>>arrB[i];

int ASum=0,BSum=0;

for(int i=0;i<n;i++)ASum+=arrA[i];

for(int i=0;i<n-1;i++)BSum+=arrB[i];

int ans=-1;

for(int i=0;i<n;i++){

int rhs=(ASum-arrA[i]);

int lhs=(BSum-rhs);

int nMinus1=n-1;

if(lhs>0&&(lhs%nMinus1)==0){

int x=(lhs/nMinus1);

if(BSum-(n-1)*x==ASum-arrA[i]){

if(ans==-1)ans=x;

else ans=min(ans,x);

}

}

}

cout<<ans<<"\n";

}

return 0;

}

i dont know whats wrong in here can anyone help…

link Contest Page | CodeChef