#include using namespace std; typedef long long ll; template bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;} template bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;} int dx[4]={0,1,-1,0}; int dy[4]={1,0,0,-1}; signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); int n; cin>>n; ll a[n],b[n]; ll sum = 0; for(int i=0;i>a[i]; sum += a[i]; } for(int i=0;i>b[i]; sum -= b[i]; } if(n == 2){ if(a[0] >= b[0] && a[1]<=b[1] && a[0]-b[0] == b[1]-a[1])cout << b[1] - a[1] << endl; else if(a[0] <= b[0] && a[1] >= b[1] && a[1]-b[1] == b[0]-a[0])cout << b[0] - a[0] << endl; else cout << -1 << endl; return 0; } // sum -= (n-2)*k if(sum % (n-2)){ cout << "-1\n"; return 0; } ll now = 0; int cnt = 0; bool pos = 1; for(int i=0;i 1 || now>sum/(n-2))cout << -1 << endl; else cout << sum / (n-2) << endl; }