#include #include #include #include #include #include #include #include #include #include #include using namespace std; #define FOR(x,y) for(int x = 0;x < (y);x++) #define LLI long long int #define FORR(x,arr) for(auto& x:arr) #define ALL(a) (a.begin()),(a.end()) #define _L(x) cout<<(x)< class UF { public: vector _parent,_rank; UF() { _parent=_rank=vector(um,0); for(int i=0;i_rank[yRoot]) { _parent[xRoot] = yRoot; return yRoot; } if(_rank[xRoot]<_rank[yRoot]) { _parent[yRoot] = xRoot; return xRoot; } if(xRoot != yRoot) { _parent[yRoot] = xRoot; _rank[xRoot]++; return xRoot; } return xRoot; } }; int dp[(1 << 16) + 1]; int main() { LLI n; cin >> n; int x, y; cin >> x >> y; if(y <= x) { cout << -1 << endl; return 0; } int answer = y - x; for(int i = 0; i < n - 1;i++) { cin >> x >> y; if(answer != (y-x)) { cout << -1 << endl; return 0; } } cout << answer << endl; return 0; }