// yukicoder: No.185 和風 // 2019.4.13 bal4u #include //// 高速入力 #if 1 #define gc() getchar_unlocked() #define pc(c) putchar_unlocked(c) #else #define gc() getchar() #define pc(c) putchar(c) #endif int in() // 非負整数の入力 { int n = 0, c = gc(); do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0'); return n; } int main() { int N, x, ans; N = in(); x = in(), ans = in() - x; if (ans <= 0) ans = -1; if (ans > 0) while (--N) { x = in(); if (in() - x != ans) { ans = -1; break; } } printf("%d\n", ans); return 0; }