#include #include #include #include #include using namespace std; int main(){ int n,x0,y0; cin >> n; cin >> x0 >> y0; int tmp = y0 - x0; for (int i = 0; i < n - 1; i++) { int x,y; cin >> x >> y; if (tmp != y - x) { tmp = -1; break; } } if (tmp <= 0) { cout << -1 << "\n"; }else{ cout << tmp << "\n"; } return 0; }