#include using namespace std; int main(){ int N; cin>>N; setS; for(int i=0;i>x>>y; S.insert(y-x); } if(S.size()!=1||*(S.begin())<0){ cout<<-1<