#include <bits/stdc++.h>
// depends on: -

/*
usage:

tools::dijkstra<int> calculator(node_count);
calculator.add_edge(from_node, to_node, cost);
std::vector<int> distances = calculator.calc(start_node);
*/

namespace tools {
  template <typename T> class dijkstra {
  private:
    std::vector<T> distances;
    std::vector<std::size_t> prev_nodes;
    std::priority_queue<std::pair<T, std::size_t>, std::vector<std::pair<T, std::size_t>>, std::greater<std::pair<T, std::size_t>>> tasks;
    std::vector<std::unordered_map<std::size_t, T>> edges;

  public:
    static constexpr std::size_t NONE = std::numeric_limits<std::size_t>::max();

    dijkstra(const std::size_t node_count) :
      distances(node_count),
      prev_nodes(node_count),
      tasks(),
      edges(node_count) {
    }

    void add_edge(const std::size_t from, const std::size_t to, const T distance) {
      this->edges[from].insert(std::make_pair(to, distance));
    }

    std::vector<T> calc(const std::size_t start_node) {
      assert(start_node < this->distances.size());
      this->distances.assign(this->distances.size(), std::numeric_limits<T>::max());
      this->prev_nodes.assign(this->prev_nodes.size(), std::size_t(NONE));
      this->tasks.push(std::make_pair(0, start_node));
      while (!this->tasks.empty()) {
        const std::pair<T, std::size_t> task = this->tasks.top();
        this->tasks.pop();
        const T& distance = std::get<0>(task);
        const std::size_t& target_node = std::get<1>(task);
        if (this->distances[target_node] != std::numeric_limits<T>::max()) {
          // old task for already visited node
          continue;
        }
        this->distances[target_node] = distance;
        for (const std::pair<std::size_t, T>& edge : this->edges[target_node]) {
          const std::size_t& next_node = std::get<0>(edge);
          const T new_distance = distance + std::get<1>(edge);
          if (new_distance < this->distances[next_node]) {
            this->prev_nodes[next_node] = target_node;
            this->tasks.push(std::make_pair(new_distance, next_node));
          }
        }
      }
      return this->distances;
    }
  };
}

int main() {
  std::int_fast64_t n, m, r;
  std::cin >> n >> m >> r;
  std::vector<std::int_fast64_t> targets(r);
  std::copy_n(std::istream_iterator<std::int_fast64_t>(std::cin), r, targets.begin());
  std::transform(targets.begin(), targets.end(), targets.begin(), [](const std::int_fast64_t target) { return target - 1; });

  tools::dijkstra<std::int_fast64_t> calculator(n);
  for (std::int_fast64_t i = 0; i < m; ++i) {
    std::int_fast64_t a, b, c;
    std::cin >> a >> b >> c;
    calculator.add_edge(a - 1, b - 1, c);
    calculator.add_edge(b - 1, a - 1, c);
  }

  std::vector<std::vector<std::int_fast64_t>> distances(r, std::vector<std::int_fast64_t>(r, 0));
  for (std::int_fast64_t i = 0; i < r; ++i) {
    const std::int_fast64_t from = targets[i];
    const std::vector<std::int_fast64_t>& dijkstra_result = calculator.calc(from);
    for (std::int_fast64_t j = 0; j < r; ++j) {
      const std::int_fast64_t to = targets[j];
      distances[i][j] = dijkstra_result[to];
    }
  }

  std::int_fast64_t min_distance = std::numeric_limits<std::int_fast64_t>::max();
  std::vector<std::int_fast64_t> indices(r);
  std::iota(indices.begin(), indices.end(), 0);
  do {
    std::vector<std::int_fast64_t> inner_indices(r - 1);
    std::iota(inner_indices.begin(), inner_indices.end(), 0);
    min_distance = std::min(
      min_distance,
      std::accumulate(
        inner_indices.begin(),
        inner_indices.end(),
        static_cast<std::int_fast64_t>(0),
        [&distances, &indices](const std::int_fast64_t sum, const std::int_fast64_t i) {
          return sum + distances[indices[i]][indices[i + 1]];
        }
      )
    );
  } while (std::next_permutation(indices.begin(), indices.end()));

  std::cout << min_distance << std::endl;
  return 0;
}

Measured memory_bytes: 2952