#include #include #include #include #include #include #include #include #include #include #include #include #define FOR(i, a, b) for(int i=(a);i<=(b);i++) #define RFOR(i, a, b) for(int i=(a);i>=(b);i--) #define MOD 1000000007 #define INF 1000000000 using namespace std; int main(void) { int n; int point; bool flag = false; cin >> n; FOR(i, 1, n) { int a, b; cin >> a >> b; if (i == 1) { point = b - a; } else { if (b - a != point&&flag==false) { point = -1; flag = true; } } } cout << point << endl; return 0; }