import sys input = sys.stdin.readline N=int(input()) AB=[list(map(int,input().split())) for i in range(N)] SA=0 SB=0 ANS=0 for i in range(N-1,-1,-1): a,b=AB[i] if a*SB>b*SA: ANS+=a*SB else: ANS+=b*SA SA+=a SB+=b print(ANS)