#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int N, M;
	int road[1001],weather[1001];
	cin >> N >> M;
	for (int i = 1; i <= N; ++i) {
		cin >> road[i];
	}
	for (int i = 1; i <= M; ++i) {
		cin >> weather[i];
	}
	int *map[1001];
	map[0] = new int[M - N + 2]{0};
	for (int i = 1; i <= N; ++i) {
		map[i] = new int[M - N + 2];
		map[i][0] = 2000000000;
		for (int j = 1; j <= M - N + 1; ++j) {
			map[i][j] = min(map[i][j - 1], road[i] * weather[i + j - 1] + map[i - 1][j]);
		}
	}
	cout << map[N][M - N + 1] << endl;
	return 0;
}