//package Qd
import java.util.*
import java.math.*
import java.lang.Math.*
import java.nio.IntBuffer


private val readString: ()->String = {readLine()!!}
private val readInt: ()->Int = {readLine()!!.toInt()}
private val readLong: ()->Long = {readLine()!!.toLong()}
private val readIntArray: ()->IntArray = {readLine()!!.split(' ').map{it.toInt()}.toIntArray()}
private val readLongArray: ()->LongArray = {readLine()!!.split(' ').map{it.toLong()}.toLongArray()}
private val errPrintln: (String)->Unit = {msg -> System.err.println(msg)}
private val MOD = 1e9.toLong()+7
private val INF = Int.MAX_VALUE/2
private val LINF = Long.MAX_VALUE/2

private fun permutation(A: IntArray): List<IntArray> {
    val ary = A.sorted()
    val N = ary.size
    val used = BooleanArray(N){false}
    val hm = HashMap<IntBuffer, IntArray>()
    val ptn = ArrayList<Int>(0)
    fun dfs(n: Int) {
        if (n >= N) {
            val value = ptn.toIntArray()
            val key = IntBuffer.wrap(value)
            hm[key] = value
        }
        for (i in 0 until N) {
            if (used[i]) continue
            used[i] = true
            ptn.add(ary[i])
            dfs(n+1)
            ptn.removeAt(ptn.lastIndex)
            used[i] = false
        }
    }
    dfs(0)
    val res = ArrayList<IntArray>()
    for (key in hm.keys.sorted()) {
        res.add(hm[key]!!)
    }
    return res.toList()
}

data class To(val idx: Int, val cost: Long)
private class Warshall(val eg: Array<ArrayList<To>>) {
    private var dist = Array(0){LongArray(0)}
    init {
        val N = eg.size
        dist = Array(N){LongArray(N){LINF}}
        for (i in 0 until N) {
            dist[i][i] = 0
        }
        for (s in 0 until N) {
            for (t in eg[s]) {
                dist[s][t.idx] = t.cost
                dist[t.idx][s] = t.cost
            }
        }
        for (k in 0 until N) {
            for (i in 0 until N) {
                if (dist[i][k] == LINF) continue
                for (j in 0 until N) {
                    if (dist[k][j] == LINF) continue
                    if (dist[i][j] > dist[i][k] + dist[k][j]) {
                        dist[i][j] = dist[i][k] + dist[k][j]
                    }
                }
            }
        }
    }
    fun distance(i: Int, j: Int): Long {
        return dist[i][j]
    }
    fun hasNegativeCycle(): Boolean {
        val N = dist.size
        var res = false
        for(i in 0 until N) {
            if (dist[i][i] < 0) {
                res = true
                break
            }
        }
        return res
    }
}

private fun solveD(R: IntArray, eg: Array<ArrayList<To>>): Long {
    val patterns = permutation(R)

    val ws = Warshall(eg)

    var res = LINF
    for (cities in patterns) {
        var distSum = 0L
        val K = cities.size
        for (i in 0 until K-1) {
            distSum += ws.distance(cities[i], cities[i+1])
        }
        res = min(res, distSum)
    }

    return res
}


fun main(args: Array<String>) {
    val (N, M, K) = readIntArray()
    val R = readIntArray().map{ it-1 }
    val eg = Array(N) {ArrayList<To>()}
    for (i in 0 until M) {
        var (a, b, c) = readIntArray()
        a--; b--;
        eg[a].add(To(b, c.toLong()))
        eg[b].add(To(a, c.toLong()))
    }

    val ans = solveD(R.toIntArray(), eg)

    println(ans)
}


Measured memory_bytes: 57284