n=int(input())

i=1
an=0
f={}
while i<=n:
    x,y=map(int,input().split())
    a=f.get(x,0)
    an+=i*a
    f[x]=y
    i+=1
print(an&((1<<64)-1))