#include #include #include #include using namespace std; typedef long long int ll; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; int ans=-1; for(int i=0;i> x >> y; if(x==y){ cout << -1 << endl; return 0; } if(y-x>0&&(ans==-1||ans==y-x)){ ans=y-x; } else{ cout << -1 << endl; return 0; } } cout << ans << endl; }