#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define INF (INT_MAX/3) #define PI (2*acos(0.0)) #define EPS (1e-8) typedef long long ll; typedef unsigned long long ull; int main(){ ios_base::sync_with_stdio(0); int N, x, y; cin >> N >> x >> y; int ans = y - x; for(int i = 1; i < N; i++){ cin >> x >> y; if(y - x != ans){ ans = -1; break; } } if(ans < 0) cout << -1 << endl; else cout << ans << endl; return 0; }