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