#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]


macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    ($arg:expr) => (println!("{:?}",$arg));
}


#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}


use std::cmp;
use std::collections::HashMap;




pub struct CALCDFS{
    visit : Vec<i32>,
    used : Vec<bool>,
    dp : Vec<Vec<i64>>,
    perm : Vec<usize>,
    ans : i64,
}

impl CALCDFS{
    pub fn new (n:usize ,m:usize,r:usize)-> Self{
        let max = 99999999999_i64;
        CALCDFS{
            visit : vec![0;r],
            used : vec![false;10],
            dp :  vec![vec![max;n];n],
            perm : vec![0;r],
            ans : max
        }
    }

    pub fn dfs (&mut self , count : i32 ){
        if(count == (self.visit.len() as i32) ){
            let mut sum =0_i64;
            for i in 0..self.perm.len()-1{
                let a = self.visit[self.perm[i]] as usize;
                let b = self.visit[self.perm[i+1]] as usize;
                sum += self.dp[a][b];
            }
            self.ans = cmp::min(self.ans, sum );
            return;
        }
       
        for i in 0..self.visit.len(){
            if(self.used[i]){
                continue;
            }
            self.used[i] = true;
            self.perm[count as usize] = i;
            self.dfs( count+1);
            self.used[i] = false;
        }

    }
}




fn main() {

    input! { 
       n: usize,
       m: usize,
       r : usize,
       visit : [i32;r],
       a : [(usize,usize,i64);m]
    }


    let mut dfs = CALCDFS::new(n,m,r);
    for i in 0..r{
        dfs.visit[i] = visit[i]-1;
    }

    

    for i in 0..m{
        let (a,b,c) = a[i];
        dfs.dp[a-1][b-1] = c;
        dfs.dp[b-1][a-1] = c;
        //dp[i][i] = 0;
    }

    //dfs.dp[0][0] = 0;
    for k in 0..n{
        for i in 0..n{
            for j in 0..n{
                dfs.dp[i][j] = cmp::min(
                    dfs.dp[i][j],
                    dfs.dp[i][k] + dfs.dp[k][j]                    
                )
            }
        }
    }



    
    dfs.dfs(0);


    
    println!("{}",dfs.ans);


}


Measured memory_bytes: 4352