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 = AdjacentListGraph<Int, Long>(Array(N) { Vertex<Int, Long>(0) }.toMutableList())
    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): Boolean {
        edges.add(Edge(to, weight))
        return true
    }

    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((E+V)logV)
    */
    val distances = Array(graph.size) { Long.MAX_VALUE }
    data class Node(val index: Int, val dist: Long) : Comparable<Node> {
        override fun compareTo(other: Node) = when {
            (dist == other.dist && index == other.index) -> 0
            (dist > other.dist) -> 1
            else -> -1
        }
    }
    // sorted by distance
    val ts = TreeSet<Node>()
    distances[from] = 0L
    ts.add(Node(from, 0L))
    while (ts.isNotEmpty()) {
        val node = ts.pollFirst()!!
        for (edge in graph.edgesFrom(node.index)) {
            val altDist = node.dist + edge.weight
            // println("$node, ${distances[node]}, $edge, $altDist")
            if (altDist < distances[edge.to]) {
                distances[edge.to] = altDist
                ts.add(Node(edge.to, altDist))
            }
        }
    }
    return distances
}

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 }
}
