#include using namespace std; int main() { int n;cin>>n; int a,b,c=-1; for(int i=0;i>a>>b; if(c==-1)c=b-a; else if(c!=b-a){cout<<-1<