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