#include using namespace std; using ll = long long; constexpr ll MOD = ((1e9) + 7); int main() { int N; ll res = 0; cin >> N; for (int i = 0; i < N; i++) { ll C, D; cin >> C >> D; if (C & 1) { C %= MOD; D %= MOD; res += (C + 1) / 2 * D; } else { C %= MOD; D %= MOD; res += C / 2 * D; } } cout << res << endl; return 0; }