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