package main import ( "bufio" "fmt" "os" "strconv" ) func main() { var N, X, Y, rlt int sc := bufio.NewScanner(os.Stdin) sc.Split(bufio.ScanWords) sc.Scan() N, _ = strconv.Atoi(sc.Text()) sc.Scan() X, _ = strconv.Atoi(sc.Text()) sc.Scan() Y, _ = strconv.Atoi(sc.Text()) rlt = Y - X if rlt <= 0 { fmt.Println("-1") return } for i := 0; i < N-1; i++ { sc.Scan() X, _ = strconv.Atoi(sc.Text()) sc.Scan() Y, _ = strconv.Atoi(sc.Text()) if rlt != Y-X { fmt.Println("-1") return } } fmt.Println(rlt) }