const DIVISOR: u64 = 10u64.pow(9) + 7; fn main() { let mut input = String::new(); std::io::Read::read_to_string(&mut std::io::stdin(), &mut input).ok(); let input: Vec = input .split_whitespace() .skip(1) .map(|n| n.parse().unwrap()) .collect(); let mut answer = 0; for cd in input.chunks(2) { answer += (cd[1] % DIVISOR) * (((cd[0] + 1) / 2) % DIVISOR); answer %= DIVISOR; } println!("{}", answer); }