#include using namespace std; int main() { int N; cin >> N; vector C( N ); vector D( N ); for( int i = 0; i < N; i++ ) { cin >> C[i] >> D[i]; } const long long m = 1000000000 + 7; long long ans = 0; for( int i = 0; i < N; i++ ) { long long c = C[i] / 2; if( C[i] % 2 ) c++; c %= m; D[i] %= m; ans += c * D[i] % m; ans %= m; } cout << ans << endl; }