N,M=map(int, input().split()) A=list(map(int, input().split())) D=[[] for i in range(N)] G=[0]*N from collections import deque d=deque() for i in range(N-1): u,v=map(int, input().split()) u-=1;v-=1 D[u].append(v);D[v].append(u) G[u]+=1;G[v]+=1 C=list(map(int, input().split())) P=[0]*N for c in C: d.append(c-1) P[c-1]=1 import heapq E=[] for i in range(N): if G[i]==1 and P[i]==0: heapq.heappush(E,(-A[i],i)) ans=0 for i in range(N): while E: x,y=heapq.heappop(E) if P[y]==0: ans-=x for nex in D[x]: G[nex]-=1 if G[nex]==1 and P[nex]==0: heapq.heappush(E,(-A[nex],nex)) break nd=deque() while d: now=d.popleft() for nex in D[now]: if P[nex]==0: P[nex]=1 nd.append(nex) d=nd print(ans)