n=int(input())
levo=[]
desno=[]
lhp=[]
dhp=[]
sekunde=0
for i in range(n):
    [poz,hp]=list(map(int,input().split(" ")))
    if poz>0:
        desno.append([hp,poz])
        dhp.append(hp)
    else:
        levo.append([hp,abs(poz)])
        lhp.append(hp)
        
levo.sort()
desno.sort()

if sum(dhp)>sum(lhp):
    index=len(dhp)-1
    while sum(dhp[0:index])>sum(lhp):
        dhp.pop(index)
        desno.pop(index)
        index-=1
    for x in levo:
        sekunde+=x[0]*x[1]*2
    for y in desno[0:-1]:
        sekunde+=y[0]*y[1]*2
    sekunde+=((sum(lhp)-sum(dhp[0:-1]))*2+1)*desno[-1][1]

else:
    index=len(lhp)-1
    while sum(lhp[0:index])>sum(dhp):
        lhp.pop(index)
        levo.pop(index)
        index-=1

    for x in desno:
        sekunde+=x[0]*x[1]*2
    for y in levo[0:-1]:
        sekunde+=y[0]*y[1]*2
    sekunde+=((sum(dhp)-sum(lhp[0:-1]))*2-1)*levo[-1][1]

sekunde%=10**9+7
print(sekunde)