def main(): N = int(input()) CD = tuple(tuple(map(int, input().split())) for _ in [0] * N) n = 0 m = 1000000007 for c, d in CD: c = c % m d = d % m n += (c + 1) // 2 * d n = n % m print(n) main()