#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

long long int DP[2000];

int main(){
	
	int N, M;
	
	cin >> N >> M;
	
	for(int i = 0; i < 2000; i++){
		DP[i] = 1000000000000;
	}
	
	long long int D[2000], C[2000];
	
	for(int i = 0; i < N; i++){
		cin >> D[i];
	}
	
	for(int i = 0; i < M; i++){
		cin >> C[i];
	}
	
	DP[0] = 0;
	
	for(int i = 0; i < M; i++){
		for(int j = N; j >= 1; j--){
			DP[j] = min(DP[j], DP[j - 1] + C[i] * D[j - 1]);
			//cout << DP[j] << " ";
		}
		//cout << endl;
	}
	
	cout << DP[N] << endl;
	
	return 0;
}