#include using namespace std; int main() { int N, X[1000], Y[1000]; cin >> N; for(int i = 0; i < N; i++) { cin >> X[i] >> Y[i]; } int ret = Y[0] - X[0]; for(int i = 0; i < N; i++) { if(Y[i] - X[i] != ret || ret <= 0) { cout << -1 << endl; } } cout << ret << endl; }