// No.185 和風 package main import "fmt" func main() { var n int fmt.Scan(&n) type Data struct { X int Y int } list := make([]Data, n) for i := 0; i < n; i++ { fmt.Scan(&list[i].X, &list[i].Y) } ans := max(list[0].Y-list[0].X, 0) for _, v := range list { if ans == 0 || ans+v.X != v.Y { ans = -1 break } } fmt.Println(ans) }