#include #include #include #include #include using namespace std; int main() { int n, x, y; int ans; cin >> n; for (int i = 0; i < n; i++) { cin >> x >> y; if (i == 0) { ans = y - x; if (ans <= 0) { cout << -1 << endl; return 0; } } if (ans != y - x) { cout << -1 << endl; return 0; } } cout << ans << endl; return 0; }