[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 is an integer array of size 1005
g is an integer array of size 1005
in function find with parameter integer x and return integer
    return f[x] if f[x] equals x, otherwise return call find with f[x]
end of the block
in function clear
    for i = 0 to 1005 exclusive, set f[i] to i
end of the block
define the main function
    call memset with g, 0, call sizeof with g
    call clear
    n, m, k are integers
    read n, m, k
    i and j are integers
    for i = 0 to k exclusive
        declare an integer gov
        read gov
        assign 1 to g[gov]
    end of the block
    for i = 0 to m exclusive
        x and y are integers
        read x, y
        if g[x] equals 1
            assign x to f[call find with y]
        else if g[y] equals 1
            assign y to f[call find with x]
        else
            if g[call find with x] equals 1
                set f[call find with y] to f[call find with x]
            else if g[call find with y] equals 1
                set f[find call with x] to f[find call with y]
            else
                set f[find call with y] to f[find call with x]
        end of the block
    end of the block
    ans is an integer set to 0
    maxx is an integer set to 0
    temp is an integer
    for i = 1 to n inclusive
        assign 1 to temp
        if g[i]
            for j = 1 to n inclusive
                if i isn't equal to j and not g[j] and f[call find with j] equals i, increment temp
            end of the block
            add temp * (temp - 1) / 2 to ans
            set maxx to call max with maxx, temp
        end of the block
    end of the block
    cnt is an integer set to 0
    for i = 1 to n inclusive
        if not g[i] and not g[f[call find with i]], increment cnt
    end of the block
    add maxx * cnt to ans
    add cnt * (cnt - 1) / 2 to ans
    subtract m from ans
    display 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;
}