object Main { def main(args: Array[String]) { val sc = new java.util.Scanner(System.in) val n = sc.nextInt val mod = 1e9.toInt + 7 var ans = 0L for (i <- 0 to n-1) { val c, d = sc.nextLong // println(c, d) // c 個の椅子がある机に座れる人数 val n = (c / 2) + (c % 2) ans = (ans + (n % mod) * (d % mod)) % mod } println(ans) } }