#include #define LL long long using namespace std; int main (){ cin.tie(0); ios::sync_with_stdio(false); LL n; cin >> n; LL res{0}; const LL mod = 1000000007; for( LL i = 0; i < n; i++ ) { LL c, d; cin >> c >> d; if( ( c % 2 ) != 0 ) { c += 1; } res += ( ( c / 2 ) % mod ) * ( d % mod ); res %= mod; } cout << res << endl; return 0; }