#include <iostream>
#include <cstring>
#include <algorithm>
#define INF (2 << 28)
using namespace std;

int N, M, d[1000], c[1001], dp[1001][1001];

int rec(int now, int day) {
    
    if(now == N) return 0;
    if(day > M) return INF;
    if(~dp[now][day]) return dp[now][day];
     
    return dp[now][day] = min(rec(now, day + 1), rec(now + 1, day + 1) + d[now] * c[day]);
 }

int main() {
    
    cin >> N >> M;
    for(int i = 0; i < N; i++) cin >> d[i];
    for(int i = 0; i < M; i++) cin >> c[i + 1];
    
    memset(dp, -1, sizeof(dp));
    cout << rec(0, 1) << endl;
}