object Main extends App{
  case class Input(p: Seq[Long], q: Seq[Long])

  def kruskal(p: Seq[Long], q: Seq[Long]): Long = {
    type Node = Option[(Int, Int)]

    case class Edge(n1: Node, n2: Node, cost: Long)
    case class Graph(vs: Set[Node], es: Set[Edge])

    val pn = p.last
    val qn = q.last

    import scala.collection.mutable
    val nodes: Set[Node] =
      (0 until p.size map { i => Option((i, q.size - 1)): Node }).toSet ++
      (0 until p.size map { i => Option((p.size - 1, i)): Node }).toSet +
      None

    val F = mutable.Set[Graph]() ++ (nodes map { n => Graph(Set(n), Set()) })
    val S = mutable.Set[Edge]()
    S ++= p.init.zipWithIndex map {
      case (cost, index) => Edge(Option((index, q.size - 1)), Option((index + 1, q.size - 1)), cost)
    }
    S ++= q.init.zipWithIndex map {
      case (cost, index) => Edge(Option((p.size - 1, index)), Option((p.size - 1, index + 1)), cost)
    }
    S ++= (0 to p.size - 2) map { index => Edge(Option((index, q.size - 1)), None, qn) }
    S ++= (0 to q.size - 2) map { index => Edge(Option((p.size - 1, index)), None, pn) }
    S += Edge(Option((p.size - 1, q.size - 1)), None, Math.min(pn, qn))

    def loop() {
      val edge = S minBy (_.cost)
      S -= edge

      val t1 = F find (_.vs contains edge.n1)
      val t2 = F find (_.vs contains edge.n2)

      (t1, t2) match {
        case (Some(x1), Some(x2)) if x1 != x2 =>
          F -= x1
          F -= x2
          F += Graph((x1.vs ++ x2.vs), x1.es ++ x2.es + edge)
        case _ =>
      }

      if (S.nonEmpty) loop()
    }

    loop()
    (F.toSeq(0).es.toSeq map {_.cost}).sum
  }

  def solve(input: Input): Long = {
    val Input(p, q) = input

    (p.size, q.size) match {
      case (0, _) => q.sum
      case (_, 0) => p.sum
      case _ =>
        val prev = solve(Input(p.init, q.init)) - p.init.sum - q.init.sum
        val b = kruskal(p, q)

        prev + p.sum + q.sum + b
    }
  }

  def parse() = {
    val lines = io.Source.stdin.getLines().toList
    val regex = "(\\d+) (\\d+)".r
    val (w, h) = lines.head match {
      case regex(w, h) => (w.toInt, h.toInt)
    }
    val p = (lines drop 1 take w) map (_.toLong)
    val q = (lines takeRight h) map (_.toLong)

    Input(p, q)
  }

  val input = parse()
  val retval = solve(input)
  println(retval)
}