n = int(input()) AB = [list(map(int,input().split())) for i in range(n)] sA,sB = 0,0 for a,b in AB: sA += a sB += b ans = 0 for a,b in AB: sA -= a sB -= b ans += max(sA*b,sB*a) print(ans)