N=int(input()) G=[0]*N D=[0]*N for i in range(N): G[i],D[i]=(int(i) for i in input().split()) F=[0]*N M=0 d=0 for i in range(N): F[i]-=30000*D[i] F[i]+=G[i] if M