import math mod = 10 ** 9 + 7 N = input() res = 0 for i in range(N): C,D = map(int, raw_input().split()) a = ((C + 1) / 2.0) % mod b = D % mod res += a * b res %= mod print res