#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; long long MOD = 1000000007; int main() { int N; long long C, D, sum = 0; cin >> N; for (int i = 0; i < N; i++) { cin >> C >> D; C = (C + 1) / 2 % MOD; D %= MOD; sum += C * D % MOD; sum %= MOD; } cout << sum << endl; return 0; }