#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>

using namespace std;
static const int INF = 1e9;
int ans = INF;
int dp[1001][1001];

void solve()
{
	int N, M;
	cin >> N >> M;
	vector<int> D(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> D[i];
	}
	vector<int> C(M);
	for (int i = 0; i < M; ++i)
	{
		cin >> C[i];
	}
	for (int i = 0; i <= N; ++i)
	{
		for (int j = 0; j <= M; ++j)
		{
			dp[i][j] = INF;
		}
	}
	for (int i = 0; i < M; ++i)
	{
		dp[0][i] = 0;
	}
	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j < M; ++j)
		{
			dp[i + 1][j + 1] = min(dp[i + 1][j], dp[i][j] + D[i] * C[j]);
		}
	}
	cout << dp[N][M] << endl;
}

int main()
{
	solve();
	return(0);
}