N = int(input()) C = [0] * N D = [0] * N for i in range(N): C[i], D[i] = map(int, input().split()) INF = pow(10, 12) dp = [INF] * (N+1) dp[0] = 0 for i in range(N): dp[i+1] = min(dp[i+1], dp[i] + C[i] * 2) if i >= 1: dp[i+1] = min(dp[i+1], sum(C[:i+1]) + min(C[:i+1]) + sum(D[:i+1]) - D[0]) for j in range(i): dp[i+1] = min(dp[i+1], dp[j] + sum(C[j:i+1]) + min(C[j:i+1]) + sum(D[j:i+1]) - D[j]) print(dp[N])