#include using namespace std; typedef long long ll; const ll MOD = 1e9 + 7; int main(){ int N; cin >> N; ll res = 0; while(N--){ ll C, D; cin >> C >> D; C = (C + 1) / 2; C %= MOD; D %= MOD; res = (res + C * D % MOD) % MOD; } cout << res << endl; return 0; }