#include #include #include #include #include #include ///////// #define REP(i, x, n) for(int i = x; i < n; i++) #define rep(i,n) REP(i,0,n) #define P(p) cout<<(p)<>N;//[1,10^3] int x[1000],y[1000]; int ans = -1; int temp; rep(i,N){ cin>>x[i]>>y[i]; if(x[i]>y[i]){P(-1);return 0;} temp = y[i]-x[i]; if( ans != -1 && ans != temp){ P(-1);return 0; } ans = temp; } if(ans == 0){ P(-1); }else{ P(ans); } return 0; }