package main import "fmt" func main() { var N, X, Y, rlt int fmt.Scan(&N) fmt.Scan(&X, &Y) rlt = Y - X if rlt <= 0 { fmt.Println("-1") return } for i := 0; i < N-1; i++ { fmt.Scan(&X, &Y) if rlt != Y-X { fmt.Println("-1") return } } fmt.Println(rlt) }