#include int main(void) { // your code goes here int n, i; long x, y, ans; fscanf(stdin, "%d", &n); fscanf(stdin, "%ld %ld", &x, &y); ans = y - x; if (ans < 0) ans = -1; for(i = 0; i < n; i++){ fscanf(stdin, "%ld %ld", &x, &y); if(ans != (y - x)){ ans = -1; break; } } printf("%ld\n", ans); return 0; }