#include "bits/stdc++.h" using namespace std; int main() { int n, a, b,c, f=0; cin >> n; n--; cin >> a>>b; c = b-a; if (c < 0) f=1; while (n--) { cin>>a>>b; if (b-a != c){ f=1; } } if(f==1) cout<<-1<