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