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