n, m = gets.split.map(&:to_i)
d = []
h = []
n.times{ d << gets.to_i }
m.times{ h << gets.to_i }
dp = Array.new(2){ Array.new(n+1, 1<<31) }
dp[0][0] = dp[1][0] = 0
m.times do |i|
  (0..[i,n-1].min).each do |j|
    dp[i%2^1][j+1] = [dp[i%2][j+1], dp[i%2][j] + d[j] * h[i]].min
  end
end
p dp[m%2][-1]