#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

ll d[1002],c[1002];
ll dp[1002][1002];
const ll INF=1000100010001000100;
int main(){
    int n,m;
    cin>>n>>m;
    rep(i,n) cin>>d[i];
    rep(i,m) cin>>c[i];
    rep(i,n+1)rep(j,m+1) dp[i][j]=INF;
    rep(i,m) dp[0][i]=0;
    rep(i,n)rep(j,m){
        dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+d[i]*c[j]);
        dp[i][j+1]=min(dp[i][j+1],dp[i][j]);
    }
    ll mn=INF;
    rep(i,m+1) mn=min(mn,dp[n][i]);
    cout<<mn<<endl;
    return 0;
}
