#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;
const int MAX_N=1000;
const int MAX_M=1000;
const int INF=1000000000;
int  dp[MAX_M][MAX_N];
int dis[MAX_N];
int wea[MAX_M];
int n,m;
int rec(int i,int j){
	if(j==n){
		   return 0;
	   }
	   if(i==m){
	   	   return INF;
	   }
	if(dp[i][j]>=0){
		return dp[i][j];
	}

   return dp[i][j]=min(rec(i+1,j),rec(i+1,j+1)+wea[i]*dis[j]);
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%d",&dis[i]);
	}
	for(int i=0;i<m;i++){
		scanf("%d",&wea[i]);
	}
	memset(dp,-1,sizeof(dp));

	printf("%d\n",rec(0,0));
	return 0;

}