#include #define rep(i,n) for(int i=0;i<(n);++i) #define all(a) (a).begin(),(a).end() using namespace std; typedef long long ll; int main(){ ios::sync_with_stdio(false); cin.tie(0); ll mod = 1000000007; int n; cin >> n; vector c(n); vector d(n); rep(i,n){ cin >> c[i] >> d[i]; } ll ans=0; rep(i,n){ ll k; if(c[i] % 2 == 0) k = c[i] / 2; else k = (c[i] + 1) / 2; ans += k * d[i] % mod; } cout << ans % mod << endl; return 0; }