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