#include typedef long long ll; #define INF 1000000000 #define MOD 1000000007 using namespace std; int main(void){ int n; cin>>n; ll ans=0; for(int i=0;i>c>>d; c%=MOD; d%=MOD; ans+=(((c+1)/2)%MOD)*d%MOD; ans%=MOD; } cout<