#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;

    vector<long long> heights(n);
    vector<long long> costs(n);

    for (int i = 0; i < n; ++i) {
        cin >> heights[i];
    }

    for (int i = 0; i < n; ++i) {
        cin >> costs[i];
    }

    vector<long long> dp(n);

    dp[0] = 0;

    for (int i = 1; i < n; ++i) {
        dp[i] = dp[i - 1] + costs[i] * heights[i];
        for (int j = i - 1; j >= 0; --j) {
            dp[i] = min(dp[i], dp[j] + costs[i] * heights[j]);
        }
    }

    cout << dp[n - 1] << endl;

    return 0;
}
