import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, M, R = in.next().toInt
  val r = new Array[Int](R)
  for (i <- 0 until R) {
    r(i) = in.next().toInt
  }

  val d = Array.ofDim[Long](N+1, N+1)  // d[a][b] は辺 e = (a, b) のコスト(存在しない場合はINF, ただし d[i][i] = 0 とする)
  val MAX = 100002L

  // 初期化
  for(i <- 0 to N; j <- 0 to N){
    if(i == j)
      d(i)(j) = 0
    else
      d(i)(j) = MAX
  }

  // input d
  for(i <- 0 until M) {
    val a, b, c = in.next().toInt
    d(a)(b) = c
    d(b)(a) = c
  }

  // function
  def warshall_floyd() =
    for(k <- 1 to N; i <- 1 to N; j <- 1 to N){
      d(i)(j) = Math.min(d(i)(j), d(i)(k) + d(k)(j))
    }


  // main process
  warshall_floyd()

  var ans: Long = Integer.MAX_VALUE
  for(pl <- r.toList.permutations) {
    var tmp = 0L
    for(i <- 0 until pl.length - 1) {
      tmp += d(pl(i))(pl(i+1))
    }
    ans = Math.min(ans, tmp)
  }

  println(ans)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}
