mod = pow(10, 9) + 7 n = int(input()) p = 0 for i in range(n): chair, num = map(int, input().split()) p += (chair + 1) // 2 * num p %= mod print(p)