package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

type pair struct {
	fi int
	se int
}

func Permute(nums []int) [][]int {
	n := factorial(len(nums))
	ret := make([][]int, 0, n)
	permute(nums, &ret)
	return ret
}

func permute(nums []int, ret *[][]int) {
	*ret = append(*ret, makeCopy(nums))

	n := len(nums)
	p := make([]int, n+1)
	for i := 0; i < n+1; i++ {
		p[i] = i
	}
	for i := 1; i < n; {
		p[i]--
		j := 0
		if i%2 == 1 {
			j = p[i]
		}

		nums[i], nums[j] = nums[j], nums[i]
		*ret = append(*ret, makeCopy(nums))
		for i = 1; p[i] == 0; i++ {
			p[i] = i
		}
	}
}

func factorial(n int) int {
	ret := 1
	for i := 2; i <= n; i++ {
		ret *= i
	}
	return ret
}

func makeCopy(nums []int) []int {
	return append([]int{}, nums...)
}

func convination(n int, k int) int {
	if k < 0 || n < k {
		return 0
	}
	var ret = 1
	for i := 1; i <= k; i++ {
		ret *= n
		ret /= i
		n--
	}
	return ret
}
func modconvination(n int, k int) int {
	if k < 0 || n < k {
		return 0
	}
	var ret = 1
	for i := 1; i <= k; i++ {
		ret *= n
		ret %= mod
		ret = inverseDiv(ret, i)
		n--
	}
	return ret
}
func inverseDiv(a int, b int) int {
	return a * modinv(b, mod) % mod
}

func modinv(a int, m int) int {
	b := m
	u := 1
	v := 0
	for {
		if b == 0 {
			break
		}
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= m
	if u < 0 {
		u += m
	}
	return u
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	//予備

	n := iScan()
	m := iScan()
	r := iScan()
	R := make([]int, r)
	a := make([]int, m)
	b := make([]int, m)
	c := make([]int, m)
	inf := 1000000007
	var dist = [200][200]int{}
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if i == j {
				dist[i][j] = 0
			} else {
				dist[i][j] = inf
			}
		}
	}
	for i := 0; i < r; i++ {
		R[i] = iScan()
	}
	for i := 0; i < m; i++ {
		a[i] = iScan()
		b[i] = iScan()
		c[i] = iScan()
		a[i]--
		b[i]--
		dist[a[i]][b[i]] = c[i]
		dist[b[i]][a[i]] = c[i]
	}
	for o := 0; o < n; o++ {
		for i := 0; i < n; i++ {
			for j := 0; j < n; j++ {
				if dist[i][o] == inf || dist[o][j] == inf {
					continue
				}
				dist[i][j] = smaller(dist[i][j], dist[i][o]+dist[o][j])
			}
		}
	}
	min := 1000000007

	nums := make([]int, 0)
	for i := 0; i < r; i++ {
		nums = append(nums, i)
	}
	for _, v := range Permute(nums) {
		ans := 0
		//fmt.Println(v)
		for i := 0; i < r-1; i++ {
			ans += dist[R[v[i]]-1][R[v[i+1]]-1]
		}
		if ans < min {
			min = ans
		}
	}
	fmt.Println(min)
}

Measured memory_bytes: 6556