#include #include #include #include #include #include #include #include using namespace std; typedef long long int ll; int main(){ int n; cin >> n; ll ans=0; vector c(n), d(n); for(int i=0; i> c[i] >> d[i]; ans+=((c[i]/2)%1000000000+7+c[i]%2)*d[i]; ans%=1000000000+7; } cout << ans << endl; return 0; }