import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); long sum = 0; for(int i = 0; i < N; i++) { long C = scan.nextLong(); long D = scan.nextLong(); long k; if(C% 2 == 0) { k = C / 2; k = k % (1000000007); }else { k = C / 2 + 1; k = k % (1000000007); } sum += (k * D) % (1000000007); } scan.close(); long ans = sum % (1000000007); System.out.println(ans); } }