mod=10**9+7 n=int(input()) ans=0 for _ in range(n): c,d=map(int,input().split()) ans+=(c+1>>1)%mod*d%mod if mod<=ans:ans-=mod print(ans)