n = int(input())
x_neg = []
x_poz = []
s_neg = []
s_poz = []
sekunde = 0

for i in range(n):
    xs = input()
    xs = xs.split(" ")
    if int(xs[0]) < 0:
        x_neg.append(int(xs[0]))
        s_neg.append(int(xs[1]))
    else:
        x_poz.append(int(xs[0]))
        s_poz.append(int(xs[1]))

if sum(s_neg) >= sum(s_poz):
    if max(s_neg) > sum(s_poz):
        s_neg[s_neg.index(max(s_neg))] = sum(s_poz)
    sekunde -= sum(s_neg)
else:
    if max(s_poz) > sum(s_neg):
        s_poz[s_poz.index(max(s_poz))] = sum(s_neg)
    sekunde += sum(s_poz)
        
for i in range(len(s_poz)):
    sekunde += (abs(x_poz[i]) * 2) * s_poz[i]
for i in range(len(s_neg)):
    sekunde += (abs(x_neg[i]) * 2) * s_neg[i]

print(sekunde % (pow(10, 9) + 5))