import java.util.Scanner; public class Yuki146 { int MOD = 1000000007; public Yuki146() { Scanner scanner = new Scanner(System.in); int N = scanner.nextInt(); long ans = 0; for (int i = 0; i < N; i++) { String[] d = scanner.nextLine().split(" "); long C = Long.parseLong(d[0]); long D = Long.parseLong(d[0]); C = (C + 1) / 2 % MOD; D = D % MOD; ans = ans + C * D; ans %= MOD; } System.out.println(ans); } public static void main(String[] args) { Yuki146 hoge = new Yuki146(); } }