fun main(arg: Array<String>) {
    val INF = 1L.shl(29)
    val (N, M, R) = listOfInt()
    val Ra = listOfInt(-1).toIntArray()
    val G = Array(N) { LongArray(N) { INF } }
    for (n in 0 until N) G[n][n] = 0
    repeat(M) {
        val (a, b, c) = listOfInt(-1, -1, 0)
        val C = c.toLong()
        if (G[a][b] > C) { G[a][b] = C; G[b][a] = C }
    }
//G.print("bofore")
    for (k in 0 until N) for (h in 0 until N) for (w in 0 until N) {
        G[h][w] = Math.min(G[h][w], G[h][k] + G[k][w])
    }
//G.print("after")
    var ans = INF
    val used = BooleanArray(R)
    fun dfs(c: Int, las: Int, dist: Long) {
        if (c == R) {
            if (ans > dist) ans = dist
            return
        }
        for (r in 0 until R) if(!used[r]) {
            used[r] = true
            if (las == -1) dfs(c + 1, r ,0)
            else dfs(c + 1, r, dist + G[Ra[las]][Ra[r]])
            used[r] = false
        }
    }
    dfs(0, -1, 0)
    println(ans)
}
fun Array<IntArray>.print(title: String = "") {
    System.err.println(if (title.length > 0) title else this)
    for ((index, array) in this.withIndex()) {
        System.err.print("[${index}] ")
        System.err.println(array.joinToString(", "))
    }
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt(D: Int = 0) = listOfString().map { Integer.parseInt(it) + D }
fun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }
