#include <bits/stdc++.h>
using namespace std;
int main(){
int N,M,i,j;
cin>>N>>M;
vector<int>D(N);
vector<int>C(M);
for(i=0;i<N;){cin>>D[i++];}
for(i=0;i<M;){cin>>C[i++];}
vector<vector<int> >dp(M+1,vector<int>(N+1,1<<30));dp[0][0]=0;
for(i=0;i<M;i++){for(j=0;j<=N;j++){
if(j==0){dp[i+1][j]=dp[i][j];}
else{dp[i+1][j]=min(dp[i][j],dp[i][j-1]+C[i]*D[j-1]);}}}
cout<<dp[M][N]<<endl;
return 0;}