use proconio::input; fn main() { input! { n: usize, mut xy: [(i32, i32); n], } let mut ans: i32 = -2; xy.push(xy[0]); for (x, y) in xy { ans = if ans == -2 { y-x } else if ans != y-x || x >= y{ -1_i32 } else { ans }; } println!("{}", ans); }