/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

template<typename T, typename U>
const U& get_or_default(const std::unordered_map<T, U>& m, T t, const U& dflt)
{
	auto it = m.find(t);
	if (it == m.end())
		return dflt;
	else
		return it->second;
}

template<typename T, typename U>
const U& get_or_default(const std::vector<U>& v, T t, const U& dflt)
{
	if (t < 0 || t >= v.size())
		return dflt;
	else
		return v[t];
}

template<typename V, typename W>
std::vector<std::vector<W>> warshall_floyd(const std::vector<std::unordered_map<V, W>>& graph, V n)
{
	std::vector<std::vector<W>> result;
	const std::unordered_map<V, W> empty;

	auto weight = [&graph, &empty](V i, V j) -> W {
		return get_or_default(graph[i], j, std::numeric_limits<W>::max());
	};

	result.resize(n);
	for (V i = 0; i < n; ++i) {
		result[i].resize(n);
		for (V j = 0; j < n; ++j) {
			if (i == j)
				result[i][j] = 0;
			else
				result[i][j] = weight(i, j);
		}
	}

	for (V k = 0; k < n; ++k) {
		for (V i = 0; i < n; ++i) {
			for (V j = 0; j < n; ++j) {
				if (result[i][k] < std::numeric_limits<W>::max() && result[k][j] < std::numeric_limits<W>::max() && result[i][j] > result[i][k] + result[k][j])
					result[i][j] = result[i][k] + result[k][j];
				else
					result[i][j] = result[i][j];
			}
		}
	}
	
	return result;
}

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N, M, R;
	std::vector<int> r;
	std::vector<std::unordered_map<int, long>> neighs;
	std::cin >> N >> M >> R;
	r.resize(R);
	for (auto& ri : r) {
		std::cin >> ri;
		--ri;
	}
	neighs.resize(N);
	for (int i = 0; i < M; ++i) {
		int a, b;
		long c;
		std::cin >> a >> b >> c;
		--a;
		--b;
		neighs[a][b] = c;
		neighs[b][a] = c;
	}

	auto dist = warshall_floyd(neighs, N);

	std::sort(r.begin(), r.end());

	long result = std::numeric_limits<long>::max();
	do {
		long rtmp = 0;
		for (int i = 0; i < r.size() - 1; ++i) {
			rtmp += dist[r[i]][r[i+1]];
		}
		result = std::min(result, rtmp);
	} while (std::next_permutation(r.begin(), r.end()));
	
	std::cout << result << "\n";
}


Measured memory_bytes: 2816