using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; static class Program{ const int mod=(int)1e9+7; const double eps=1e-11; static void Main(){ Sc sc=new Sc(); var n=sc.I; var a=sc.La; var b=sc.La; var h=new long[n]; long p=0; int x=-1; for(int i = 0;i0){ if(x!=-1){ Console.WriteLine(-1); return; } p=b[i]-a[i]; x=i; } } for(int i = 0;i0){a[i]+=p;} else{a[i]-=p;} h[i]=a[i]-b[i]; } long lb=-1,ub=mod,mid=0; while(lb+1!=ub){ mid=(ub+lb)/2; long g=0; for(int j = 0;j(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i