// コピーして使う! #include using namespace std; using ll = long long; using vll = vector; int main() { ll n; cin >> n; vll x(n), y(n); for (ll i = 0; i != n; i++) { cin >> x[i] >> y[i]; } ll a; a = y[0] - x[0]; for (ll i = 1; i != n; i++) { if (a != y[i] - x[i] || a <= 0) { a = -1; break; } } cout << a << endl; system("pause"); }