P = 10 ** 9 + 7 N = int(input()) ans = 0 for _ in range(N): C, D = map(int, input().split()) ans += (C + 1) // 2 * D ans %= P print(ans)