import java.util.*

fun main(args: Array<String>) {
    val (N, M, R) = readLine()!!.split(" ").map { it.toInt() }
    val r = readLine()!!.split(" ").map { it.toInt() - 1 }
    val graph = AdjacencyMatrixGraph<Int, Long>(Array(N) { Array<Long?>(N) { null } })
    repeat(M) {
        val (a, b, c) = readLine()!!.split(" ").map { it.toInt() }
        graph.addEdge(a - 1, b - 1, c.toLong())
        graph.addEdge(b - 1, a - 1, c.toLong())
    }
    val distancesFromNode = mutableMapOf<Int, Array<Long>>()
    r.forEach { distancesFromNode[it] = distancesFrom(graph, it) }
    // 1 -> 4 -> 3 = d[1][4] + d[4][3]
    val orders = r.toList().permutations()
    var ans = Long.MAX_VALUE
    for (order in orders) {
        val ret = (0 until R - 1).map { distancesFromNode[order[it]]?.get(order[it + 1])!! }.sum()
        ans = Math.min(ans, ret)
    }
    println(ans)
}

interface Graph<T : Comparable<T>, E : Comparable<E>> {
    val size: Int
    fun getWeight(from: Int, to: Int): E?
    fun edgesFrom(from: Int): List<Edge<E>>
    fun addEdge(from: Int, to: Int, weight: E): Boolean
    fun removeEdge(from: Int, to: Int): Boolean
    fun isAdjacent(from: Int, to: Int): Boolean
}

data class Edge<T : Comparable<T>>(val to: Int, val weight: T)
data class Vertex<T : Comparable<T>, E : Comparable<E>>(val data: T) {
    val edges = mutableListOf<Edge<E>>()

    fun addEdge(to: Int, weight: E) = when (edges.find { it.to == to }) {
        null -> {
            edges.add(Edge(to, weight))
            true
        }
        else -> false
    }

    fun removeEdge(to: Int): Boolean {
        for ((i, edge) in edges.withIndex()) {
            if (edge.to == to) {
                edges.removeAt(i)
                return true
            }
        }
        return false
    }
}

class AdjacentListGraph<T : Comparable<T>, E : Comparable<E>>(
    private val vertices: MutableList<Vertex<T, E>>
) : Graph<T, E> {
    override val size = vertices.size
    override fun getWeight(from: Int, to: Int): E? =
        vertices[from].edges.find { it.to == to }?.weight
    override fun edgesFrom(from: Int): List<Edge<E>> = vertices[from].edges
    override fun addEdge(from: Int, to: Int, weight: E) = vertices[from].addEdge(to, weight)
    override fun removeEdge(from: Int, to: Int) = vertices[from].removeEdge(to)
    override fun isAdjacent(from: Int, to: Int) =
        vertices[from].edges.find { it.to == to } != null
}

class AdjacencyMatrixGraph<T : Comparable<T>, E : Comparable<E>>(
    private val matrix: Array<Array<E?>>
) : Graph<T, E> {
    override val size = matrix.size
    override fun getWeight(from: Int, to: Int): E? = matrix[from][to]
    override fun edgesFrom(from: Int): List<Edge<E>> =
        matrix[from].withIndex()
            .filter { it.value != null }
            .map { Edge(it.index, it.value!!) }

    override fun addEdge(from: Int, to: Int, weight: E): Boolean {
        if (matrix[from][to] == null) {
            matrix[from][to] = weight
            return true
        }
        return false
    }

    override fun removeEdge(from: Int, to: Int): Boolean {
        if (from >= size || to >= size || matrix[from][to] == null) {
            return false
        }
        matrix[from][to] = null
        return true
    }

    override fun isAdjacent(from: Int, to: Int): Boolean = matrix[from][to] != null
}


fun <T : Comparable<T>> distancesFrom(
        graph: Graph<T, Long>, from: Int): Array<Long> {
    /**
    * Dijkstra's algorithm
    * weight must be non-negative number
    * complexity is O(V^2)
    */
    val distances = Array(graph.size) { Long.MAX_VALUE }
    val isFixed = BooleanArray(graph.size)
    val pQueue = PriorityQueue<Int>(graph.size) { a, b -> a - b }
    distances[from] = 0L
    pQueue.offer(from)
    while (pQueue.isNotEmpty()) {
        val node = pQueue.poll()
        isFixed[node] = true
        for (edge in graph.edgesFrom(node)) {
            val dist = distances[node] + edge.weight
            if (dist < distances[edge.to]) {
                distances[edge.to] = dist
                if (edge.to !in pQueue) pQueue.offer(edge.to)
            }
        }
    }
    return distances
}
inline fun <reified T : Comparable<T>, reified E : Comparable<E>> shortestPath(
    graph: Graph<T, E>,
    from: Int,
    to: Int
): List<Int> {
    val beforeNodes = IntArray(graph.size) { -1 }
    val deque = ArrayDeque<Int>()
    deque.add(from)
    while (deque.size > 0) {
        val node = deque.removeFirst()
        if (node == to) {
            val path = ArrayDeque<Int>()
            var current = to
            path.add(to)
            while (current != from) {
                current = beforeNodes[current]
                path.addFirst(current)
            }
            return path.toList()
        }
        graph.edgesFrom(node).filter { beforeNodes[it.to] == -1 }.forEach {
            beforeNodes[it.to] = node
            deque.add(it.to)
        }
    }
    return emptyList()
}

fun List<Int>.dot(other: List<Int>): Int =
    this.mapIndexed { index, value -> value * other[index] }.sum()

fun List<Long>.dot(other: List<Long>): Long =
    this.mapIndexed { index, value -> value * other[index] }.sum()

fun <T> product(vararg lists: List<T>): Sequence<List<T>> {
    fun <T> productTwoList(left: List<T>, right: List<T>): Sequence<List<T>> =
        left.asSequence().flatMap { leftElem -> right.asSequence().map { listOf(leftElem, it) } }

    fun <T> product2DListAnd1DList(list2D: Sequence<List<T>>, list1D: List<T>): Sequence<List<T>> =
        list2D.flatMap { seq -> list1D.asSequence().map { seq + it } }

    require(lists.size >= 2)
    return lists.asSequence()
        .drop(2)
        .fold(productTwoList(lists[0], lists[1])) { acc, suc -> product2DListAnd1DList(acc, suc) }
}

fun <T> Collection<T>.powerSet(): Set<Set<T>> = powerSet(this, setOf(setOf()))

private tailrec fun <T> powerSet(left: Collection<T>, acc: Set<Set<T>>): Set<Set<T>> = when {
    left.isEmpty() -> acc
    else -> powerSet(left.drop(1), acc + acc.map { it + left.first() })
}

fun <T> Set<T>.combinations(n: Int): Set<Set<T>> = when {
    n < 0 -> throw Error("n must be positive, but got $n")
    n == 0 -> setOf(setOf())
    n >= size -> setOf(toSet())
    else ->
        powerSet()
            .filter { it.size == n }
            .toSet()
}

fun <T> List<T>.insert(index: Int, element: T): List<T> = when {
    index < 0 || index > size -> throw Error("Can not insert to index = $index")
    index == 0 -> listOf(element) + this
    index == size -> this + element
    else -> dropLast(size - index) + element + drop(index)
}

fun <T> List<T>.permutations(): Set<List<T>> = when {
    isEmpty() -> setOf()
    size == 1 -> setOf(listOf(get(0)))
    else -> {
        val element = get(0)
        drop(1).permutations()
            .flatMap { sublist -> (0..sublist.size).map { i -> sublist.insert(i, element) } }
            .toSet()
    }
}

fun <T, R> Iterable<T>.scanLeft(initial: R, operation: (acc: R, T) -> R): Sequence<R> {
    var last = initial
    return this.asSequence().map { last = operation(last, it); last }
}


Measured memory_bytes: 77100