M = 10 ** 9 + 7 N = gets.to_i ans = N.times.inject(0) do |s,i| c,d = gets.split.map(&:to_i) (s + (c + 1) / 2 * d) % M end puts ans