#include <iostream>
#include <algorithm>
#define INF 1000000000
using namespace std;

int dis[1010], wea[1010],dp[2][1010];
int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 1; i <= N; i++) {
		cin >> dis[i];
	}
	for (int i = 1; i <= M; i++) {
		cin >> wea[i];
	}
	int in = 0, ou = 1;
	fill(dp[in], dp[in] + N + 1, INF);
	dp[in][0] = 0;
	for (int i = 1; i <= M; i++) {
		for (int j = 1; j <= N; j++) {
			dp[ou][j] = min(dp[in][j], dp[in][j - 1] + dis[j] * wea[i]);
		}
		swap(in, ou);
	}
	cout << dp[in][N] << endl;
	return 0;
}