#include #include #include using namespace std; int main() { vectorp; int n; cin >> n; for (int i = 0; i < n; i++){ int x, y; cin >> x >> y; if (n == 1&&y-x>=0){ cout << y - x << endl; return 0; } if (y - x > 0){ p.push_back(y - x); } } sort(p.begin(), p.end()); bool flag = false; for (int i = 0; i < p.size()-1&&p.size()>1; i++){ if (p[i] == p[i + 1]){ int c=0; for (int i2 = i+1; i2 < i + n; i2++){ if (p[i] == p[i2]){ c++; } } if (c == n - 1){ cout << p[i] << endl; flag = true; } } } if (!flag){ cout << "-1" << endl; } }