MOD = 10**9+7 N = int(input()) ans = 0 for i in range(N) : c,d = map(int,input().split()) ans += (c//2 + (c%2))*d ans %= MOD print(ans)