import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.util.Comparator; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class MinimumSpanningTree_lewin { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); OutputWriter out = new OutputWriter(outputStream); MinimumSpanningTree solver = new MinimumSpanningTree(); solver.solve(1, in, out); out.close(); } static class MinimumSpanningTree { public static boolean[] special; public int n; public int m; public int k; public int w; public long[] f(MinimumSpanningTree.Edge[] e) { int[] par = DisjointSets.createSets(n); long cost = 0; int cross = 0; int count = 0; for (int i = 0; i < e.length; i++) { if (DisjointSets.unite(par, e[i].a, e[i].b)) { cost += e[i].c; cross += e[i].s; count++; } } return new long[]{cost, cross, count}; } public void solve(int testNumber, InputReader in, OutputWriter out) { n = in.nextInt(); m = in.nextInt(); k = in.nextInt(); w = in.nextInt(); special = new boolean[n]; for (int i = 0; i < k; i++) { special[in.nextInt() - 1] = true; } MinimumSpanningTree.Edge[] es = new MinimumSpanningTree.Edge[m]; for (int i = 0; i < m; i++) { es[i] = new MinimumSpanningTree.Edge(in.nextInt() - 1, in.nextInt() - 1, in.nextInt()); } Arrays.sort(es, Comparator.comparingInt(x -> x.s)); long[] a1 = f(es); Arrays.sort(es, Comparator.comparingInt(x -> -x.s)); long[] a2 = f(es); if (a1[2] < n - 1 || w < a1[1] || w > a2[1]) { out.println(-1); return; } int lo = 0, hi = 200000; while (lo <= hi) { int mid = (lo + hi) / 2; int delta = mid - 100000; Arrays.sort(es, (a, b) -> (a.c + a.s * delta == b.c + b.s * delta) ? (a.s - b.s) : (a.c + a.s * delta - b.c - b.s * delta)); long[] x1 = f(es); Arrays.sort(es, (a, b) -> (a.c + a.s * delta == b.c + b.s * delta) ? (b.s - a.s) : (a.c + a.s * delta - b.c - b.s * delta)); long[] x2 = f(es); if (x1[1] > w) { // penalized special too little lo = mid + 1; } else if (x2[1] < w) { // penalized special too much hi = mid - 1; } else { out.println(x1[0] - (w - x1[1]) * delta); return; } } } static class Edge { public int a; public int b; public int c; public int s; public Edge(int a, int b, int c) { this.a = a; this.b = b; this.c = c; this.s = special[a] ^ special[b] ? 1 : 0; } } } static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; public InputReader(InputStream stream) { this.stream = stream; } public int read() { if (this.numChars == -1) { throw new InputMismatchException(); } else { if (this.curChar >= this.numChars) { this.curChar = 0; try { this.numChars = this.stream.read(this.buf); } catch (IOException var2) { throw new InputMismatchException(); } if (this.numChars <= 0) { return -1; } } return this.buf[this.curChar++]; } } public int nextInt() { int c; for (c = this.read(); isSpaceChar(c); c = this.read()) { ; } byte sgn = 1; if (c == 45) { sgn = -1; c = this.read(); } int res = 0; while (c >= 48 && c <= 57) { res *= 10; res += c - 48; c = this.read(); if (isSpaceChar(c)) { return res * sgn; } } throw new InputMismatchException(); } public static boolean isSpaceChar(int c) { return c == 32 || c == 10 || c == 13 || c == 9 || c == -1; } } static class OutputWriter { private final PrintWriter writer; public OutputWriter(OutputStream outputStream) { writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter(Writer writer) { this.writer = new PrintWriter(writer); } public void close() { writer.close(); } public void println(long i) { writer.println(i); } public void println(int i) { writer.println(i); } } static class DisjointSets { public static int[] createSets(int size) { int[] p = new int[size]; for (int i = 0; i < size; i++) p[i] = i; return p; } public static int root(int[] p, int x) { return x == p[x] ? x : (p[x] = root(p, p[x])); } public static boolean unite(int[] p, int a, int b) { a = root(p, a); b = root(p, b); if (a != b) { p[a] = b; return true; } return false; } } }