#!/usr/bin/env python3 N = int(input()) num = 0 mod = ((10 ** 9) + 7) for i in range(N): C, D = [int(x) for x in input().split()] num += (int((C + 1) / 2) * D % mod) num %= mod print(num % mod)