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