[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
f=array of 1005 int
g=array of 1005 int
function find (get int x, return int)
    if f[x] is x return x else (f[x] = find(f[x]), return f[x])
end of the block
function clear (no args, no return value)
    for i=0 to 1005 exclusive f[i]=i
end of the block
define the main function
    fill g with 0
    clear()
    n,m,k=int
    read n,m,k
    i,j=int
    for i=0 to k exclusive
        gov=int
        read gov
        g[gov]=1
    end of the block
    for i=0 to m exclusive
        x,y=int
        read x,y
        if g[x] is 1
            f[find(y)]=x
        else if g[y] is 1
            f[find(x)]=y
        else
            if g[find(x)] is 1
                f[find(y)]=f[find(x)]
            else if g[find(y)] is 1
                f[find(x)]=f[find(y)]
            else
                f[find(y)]=f[find(x)]
        end of the block
    end of the block
    ans=0
    maxx=0
    temp=int
    for i=1 to n inclusive
        temp=1
        if g[i]
            for j=1 to n inclusive
                if i is not j and not g[j] and f[find(j)] is i increment temp
            end of the block
            add temp*(temp-1)/2 to ans
            maxx=max(maxx,temp)
        end of the block
    end of the block
    cnt=0
    for i=1 to n inclusive
        if not g[i] and not g[f[find(i)]] increment cnt
    end of the block
    add maxx*cnt to ans
    add cnt*(cnt-1)/2 to ans
    subtract m from ans
    print ans
    return to indicate successful execution
end of the block

[CODE]:

int f[1005];
int g[1005];
int find(int x) {
    return f[x] == x ? x : f[x] = find(f[x]);
}
void clear() {
    for (int i = 0; i < 1005; i++) f[i] = i;
}
int main() {
    memset(g, 0, sizeof(g));
    clear();
    int n, m, k;
    cin >> n >> m >> k;
    int i, j;
    for (i = 0; i < k; i++) {
        int gov;
        cin >> gov;
        g[gov] = 1;
    }
    for (i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        if (g[x] == 1)
            f[find(y)] = x;
        else if (g[y] == 1)
            f[find(x)] = y;
        else {
            if (g[find(x)] == 1)
                f[find(y)] = f[find(x)];
            else if (g[find(y)] == 1)
                f[find(x)] = f[find(y)];
            else
                f[find(y)] = f[find(x)];
        }
    }
    int ans = 0;
    int maxx = 0;
    int temp;
    for (i = 1; i <= n; i++) {
        temp = 1;
        if (g[i]) {
            for (j = 1; j <= n; j++) {
                if (i != j && !g[j] && f[find(j)] == i) { temp++; }
            }
            ans += temp * (temp - 1) / 2;
            maxx = max(maxx, temp);
        }
    }
    int cnt = 0;
    for (i = 1; i <= n; i++) {
        if (!g[i] && !g[f[find(i)]]) { cnt++; }
    }
    ans += maxx * cnt;
    ans += cnt * (cnt - 1) / 2;
    ans -= m;
    cout << ans << endl;
    return 0;
}