from collections import deque
n, m, k=[int(v) for v in input().split()]
w=[int(v) for v in input().split()]
iota=[]
q={}
for j in range(m):
iota.append([int(v) for v in input().split()])
if iota[-1][0] in q:
q[iota[-1][0]].append(iota[-1][1])
else:
q[iota[-1][0]]=[iota[-1][1]]
if iota[-1][1] in q:
q[iota[-1][1]].append(iota[-1][0])
else:
q[iota[-1][1]]=[iota[-1][0]]
check=set(w)
rho=[]
for j in w:
new=deque([j])
res=1
while new:
x=new.pop()
if j in q:
for j in q[x]:
if j not in check:
new.appendleft(j)
check.add(j)
res+=1
rho.append(res)
res=0
rho.sort()
epsilon=n-sum(rho)
zeta=rho.pop()+epsilon
for j in rho:
res+=j*(j-1)//2
res+=zeta*(zeta-1)//2
print(res-m)
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define mod 1000000007
#define fi first
#define se second
using namespace std;
int n,sz[1002],fr,m,k;
int ed[1002];
vector<int>gov;
vector<int>v[1002];
int cc;
bool viz[1002];
void dfs(int nod)
{
++sz[cc];
viz[nod]=1;
for(int i=0;i<v[nod].size();++i)
{
int vecin=v[nod][i];
++ed[cc];
if(viz[vecin])
continue;
dfs(vecin);
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n>>m>>k;
for(int i=1;i<=k;++i)
{
int nr;
cin>>nr;
gov.push_back(nr);
}
for(int i=1;i<=m;++i)
{
int a,b;
cin>>a>>b;
v[a].push_back(b);
v[b].push_back(a);
}
int sol=0;
int mx=0;
for(int i=0;i<k;++i)
{
++cc;
dfs(gov[i]);
ed[cc]/=2;
if(sz[cc]>sz[mx])
mx=cc;
}
for(int i=1;i<=n;++i)
if(!viz[i])
{
cc=mx;
int prev=ed[cc];
dfs(i);
int curr=ed[cc];
ed[cc]=prev+(curr-prev)/2;
}
for(int i=1;i<=k;++i)
{
long long fr=sz[i]*(sz[i]-1)/2;
sol=sol+fr-ed[i];
}
cout<<sol;
return 0;
}
445. Add Two Numbers II | 442. Find All Duplicates in an Array |
437. Path Sum III | 436. Find Right Interval |
435. Non-overlapping Intervals | 406. Queue Reconstruction by Height |
380. Insert Delete GetRandom O(1) | 332. Reconstruct Itinerary |
368. Largest Divisible Subset | 377. Combination Sum IV |
322. Coin Change | 307. Range Sum Query - Mutable |
287. Find the Duplicate Number | 279. Perfect Squares |
275. H-Index II | 274. H-Index |
260. Single Number III | 240. Search a 2D Matrix II |
238. Product of Array Except Self | 229. Majority Element II |
222. Count Complete Tree Nodes | 215. Kth Largest Element in an Array |
198. House Robber | 153. Find Minimum in Rotated Sorted Array |
150. Evaluate Reverse Polish Notation | 144. Binary Tree Preorder Traversal |
137. Single Number II | 130. Surrounded Regions |
129. Sum Root to Leaf Numbers | 120. Triangle |