#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define Would #define you const int INF = 999999999; const int MOD = 1e9 + 7; int main() { int n, a, b, mon; cin >> n; for (int i = 0; i < n; ++i) { cin >> a >> b; if (a - b < 0) { cout << -1 << endl; return 0; } if (i == 0) { mon = a - b; } else { if (a - b != mon) { cout << -1 << endl; return 0; } } } cout << mon << endl; }