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