#include using namespace std; typedef long long ll; int main() { int n; ll c,k,sum=0,a; cin>>n; for(int i=0;i>c>>k; if(c%2)a=(c/2+1)%1000000007; else a=(c/2)%1000000007; k%=1000000007; sum+=a*k%1000000007; sum%=1000000007; } cout<