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