fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n: isize = n.trim().parse().unwrap(); let lcnt = 1isize; println!("? {}", 1); let mut lval = String::new(); std::io::stdin().read_line(&mut lval).ok(); let lval: isize = lval.trim().parse().unwrap(); let ldiff = 2*lval - lcnt; let rcnt = n-1; println!("? {}", rcnt); let mut rval = String::new(); std::io::stdin().read_line(&mut rval).ok(); let rval: isize = rval.trim().parse().unwrap(); let rdiff = 2*rval - rcnt; if ldiff == rdiff { println!("! {} {}", 2, n-1); return; } let mut lower = 1isize; let mut upper = n-1; while upper > lower { let middle = (upper + lower) / 2; println!("? {}", middle); let mut mval = String::new(); std::io::stdin().read_line(&mut mval).ok(); let mval: isize = mval.trim().parse().unwrap(); let mdiff = 2*mval - middle; if mdiff == 0 { lower = middle; upper = middle; } else if mdiff * ldiff > 0 { lower = middle + 1; } else { upper = middle; } } if upper >= n/2 { println!("! {} {}", 1, upper); } else { println!("! {} {}", upper+1, n); } }