import sys input = sys.stdin.readline N = int(input()) D = [] for i in range(N): A, B = map(int, input().split()) D.append((B, A)) D.sort(reverse=True) inf = 10 ** 18 pre = [inf] * N pre[0] = 0 for i in range(N): dp = [inf] * N for j in range(N): dp[j] = min(dp[j], pre[j] + D[i][1] + (i - j) * D[i][0]) if j: dp[j] = min(dp[j], pre[j - 1]) dp, pre = pre, dp print(pre[N//3])