#include #define F(i,n) for(int i = 0;i < n;i++) #define A {ans=-1;break;} int main(void){ int n,ans; int a[2000]; scanf("%d",&n); F(i,n*2){scanf("%d",&a[i]);} ans=a[1]-a[0]; F(i,n*2){ if(ans+a[i]!=a[i+1])A if(ans<1)A i++; } printf("%d\n",ans); return 0; }