#include #include using namespace std; using namespace atcoder; using ll = long long; using ld = long double; ll N, C, D, ans; ll mod = 1000000007; int main() { cin >> N; for (int i = 0; i < N; i++) { cin >> C >> D; if (C % 2 == 1) ans = (ans + (((C + 1) / 2) % mod * D % mod) % mod) % mod; else ans = (ans + ((C / 2) % mod * D % mod) % mod) % mod; } cout << ans << endl; return 0; }