#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define N 300000
using namespace std;
bool vis[N];
int n,m,x,y,tot,lca,ans;
int a[N],fa[N],deep[N],size[N],top[N],head[N];
int read()
{
int x=0,f=1; char ch=getchar();
while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1; ch=getchar();}
while(ch>=‘0‘&&ch<=‘9‘){x=x*10+ch-‘0‘; ch=getchar();}
return x*f;
}
struct Edge
{
int from,to,next;
}edge[N];
int add(int x,int y)
{
tot++;
edge[tot].to=y;
edge[tot].next=head[x];
head[x]=tot;
}
int dfs(int x)
{
size[x]=1;vis[x]=true;
deep[x]=deep[fa[x]]+1;
for(int i=head[x];i;i=edge[i].next)
{
int to=edge[i].to;
if(fa[x]!=to&&!vis[to])
{
fa[to]=x;
dfs(to);
size[x]+=size[to];
}
}
}
int dfs1(int x)
{
int t=0; vis[x]=true;
if(!top[x]) top[x]=x;
for(int i=head[x];i;i=edge[i].next)
{
int to=edge[i].to;
if(fa[x]!=to&&size[to]>size[t]) t=to;
}
if(t&&!vis[t])
{
top[t]=top[x];
dfs1(t);
}
for(int i=head[x];i;i=edge[i].next)
{
int to=edge[i].to;
if(fa[x]!=to&&to!=t&&!vis[to])
dfs1(to);
}
}
int LCA(int x,int y)
{
while(top[x]!=top[y])
{
if(deep[top[x]]<deep[top[y]])
swap(x,y);
x=fa[x];
}
if(deep[x]>deep[y])
swap(x,y);
return x;
}
int main()
{
n=read();a[0]=1;
for(int i=1;i<n;i++)
x=read(),y=read(),add(x,y),add(y,x);
dfs(1);memset(vis,0,sizeof(vis));
dfs1(1);m=read();//a[1]=read();
for(int i=1;i<=m;i++)
{
a[i]=read();
lca=LCA(a[i-1],a[i]);
ans+=deep[a[i-1]]+deep[a[i]]-2*deep[lca];
//printf("%d %d\n",lca,ans);
}
printf("%d",ans);
return 0;
}