#include <iostream>
#include <algorithm>
using namespace std;
#define MAX 1000000000;

int main(){
  int i,j,n,m,C[1001],D[1001],dp[1001][1001];
  cin >> n >> m;
  for( i = 1; i <= n; i++ ) cin >> D[i];
  for( i = 1; i <= m; i++ ) cin >> C[i];
  
  for( i = 0; i < 1001; i++ ) dp[i][0] = MAX;
  for( i = 0; i < 1001; i++ ) dp[0][i] = 0;
  
  for( i = 1; i <= n; i++ ){
    for( j = 1; j <= m; j++ ){
      dp[i][j] = min( dp[i][j-1],dp[i-1][j-1] + C[j] * D[i] );
    }
  }

  cout << dp[n][m] << endl;
  
  return 0;
}