N = int(input()) items = [list(map(int, input().split())) for _ in range(N)] items.sort(key=lambda x:-x[1]) # dp[i][j] := i番目の商品まで見て、j個無料で買うことにしたときの最小値 INF = 10**18 dp = [[INF]*(N+1) for _ in range(N+1)] dp[0][0] = 0 for i, (ai, bi) in enumerate(items, start=1): for j in range(i+1): # i個の商品のうち、j個は無料で買う => (i-j)個は有料 dp[i][j] = min(dp[i][j], dp[i-1][j-1]) if j < i: dp[i][j] = min(dp[i][j], dp[i-1][j]+ai+(i-j-1)*bi) num = 0 day = 0 while N: N -= 1 if day and N: N -= 1 num += 1 day ^= 1 print(dp[-1][num])