package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

type Node struct {
	edgesTo    []int
	edgesCosts []int
	cost       int
	from       int
	name       int
	index      int
}
type PriorityQueue []*Node

func (pq PriorityQueue) Len() int { return len(pq) }
func (pq PriorityQueue) Less(i, j int) bool {
	return pq[i].cost < pq[j].cost
}
func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}
func (pq *PriorityQueue) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Node)
	item.index = n
	*pq = append(*pq, item)
}
func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil
	item.index = -1
	*pq = old[0 : n-1]
	return item
}
func (pq *PriorityQueue) update(item *Node, priority int) {
	item.cost = priority
	heap.Fix(pq, item.index)
}

func dijkstra(s int, nodes []*Node) {
	n := len(nodes)
	pq := make(PriorityQueue, len(nodes))
	for i := 0; i < n; i++ {
		pq[i] = nodes[i]
	}
	heap.Init(&pq)
	pq.update(nodes[s], 0)
	for len(pq) != 0 {
		currentNode := heap.Pop(&pq).(*Node)
		currentCost := currentNode.cost
		for i, to := range currentNode.edgesTo {
			cost := currentCost + currentNode.edgesCosts[i]
			if cost < (*nodes[to]).cost {
				pq.update(nodes[to], cost)
				nodes[to].from = currentNode.name
			}
		}
	}
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(Scanner())
	m, _ := strconv.Atoi(Scanner())
	r, _ := strconv.Atoi(Scanner())
	rs := make([]int, r)
	for i := 0; i < r; i++ {
		rs[i], _ = strconv.Atoi(Scanner())
		rs[i]--
	}
	inf := 1000000007
	nodes := make([]*Node, n)
	for i := 0; i < n; i++ {
		to := make([]int, 0)
		c := make([]int, 0)
		nodes[i] = &Node{
			edgesTo:    to,
			edgesCosts: c,
			cost:       inf,
			from:       -1,
			name:       i,
			index:      i,
		}
	}
	for i := 0; i < m; i++ {
		a, _ := strconv.Atoi(Scanner())
		b, _ := strconv.Atoi(Scanner())
		c, _ := strconv.Atoi(Scanner())
		a--
		b--
		nodeA := *nodes[a]
		nodeA.edgesTo = append(nodeA.edgesTo, b)
		nodeA.edgesCosts = append(nodeA.edgesCosts, c)
		nodes[a] = &nodeA
		nodeB := *nodes[b]
		nodeB.edgesTo = append(nodeB.edgesTo, a)
		nodeB.edgesCosts = append(nodeB.edgesCosts, c)
		nodes[b] = &nodeB
	}
	ds := make([][]int, n)
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			node := *nodes[j]
			node.cost = inf
			node.from = -1
			node.name = j
			node.index = j
			nodes[j] = &node
		}
		dijkstra(i, nodes)
		x := make([]int, n)
		for j := 0; j < n; j++ {
			x[j] = (*nodes[j]).cost
		}
		ds[i] = x
	}
	stack := [][]int{[]int{}}
	remain := make([][]int, 1)
	remain[0] = make([]int, r)
	for i := 0; i < r; i++ {
		remain[0][i] = rs[i]
	}
	ans := inf
	for len(stack) != 0 {
		list := stack[len(stack)-1]
		rem := remain[len(remain)-1]
		stack = stack[:len(stack)-1]
		remain = remain[:len(remain)-1]
		if len(list) == r {
			a := 0
			for i := 0; i < r-1; i++ {
				a += ds[list[i]][list[i+1]]
			}
			if a < ans {
				ans = a
			}
		} else {
			for i := 0; i < len(rem); i++ {
				x := make([]int, len(list))
				copy(x, list)
				x = append(x, rem[i])
				y := make([]int, len(rem))
				copy(y, rem)
				y = append(y[:i], y[i+1:]...)
				stack = append(stack, x)
				remain = append(remain, y)
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504