import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}

object Main extends App {
  val INF = 1 << 20
  val Array(n, m, r) = in.readLine.split(" ").map(_.toInt)
  val t = in.readLine.split(" ").map(_.toInt - 1)

  val graph = Array.fill(n, n)(INF)
  Iterator.continually(in.readLine)
    .take(m)
    .map(_.split(" ").map(_.toInt))
    .foreach { e =>
      val v1 = e(0) - 1
      val v2 = e(1) - 1
      graph(v1)(v2) = e(2)
      graph(v2)(v1) = e(2)
    }

  def warshallFloyd():Unit = {
    for{
      k <- 1 until n
      i <- 1 until n
      j <- 1 until n
    } graph(i)(j) = math.min(graph(i)(j), graph(i)(k) + graph(k)(j))
  }
  warshallFloyd()

  val ans = t.permutations.map {a => a.tail./:(0, a.head) { (acc, i) =>
      val v1 = acc._2
      val v2 = i
      (acc._1 + graph(v1)(v2), v2)
    }._1
  }.min
  println(ans)
}