n = int(input()) desks = [[int(j) for j in input().split()] for i in range(n)] total = 0 for c, d in desks: a, m = divmod(c, 2) total += (a + m) * d print(total % 1000000007)