N = int(input()) ans = sum([d * ((c+1) // 2) for c, d in [map(int, input().split()) for _ in range(N)]]) % 1000000007 print(ans)