[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]:
declare integer array father size 1005
declare n, m, k as integers
declare find with integer x as argument, returning integer
    return x if father[x] is x, else let father[x] be run find with father[x] as argument
end of the block
declare integer array node size 1005
declare integer array fathercnt size 1005
declare integer cnt
declare integer array isgro size 1005
define the main function
    set bytes from isgro to size of isgro to value 0
    read n, m, k
    declare integer gro
    for j = 1 to n inclusive, let father[j] be j
    for i = 0 to k exclusive
        declare integer g
        read g
        let isgro[g] be 1
        let gro be g
    end of the block
    for j = 1 to n inclusive, let fathercnt[j] be 1
    for i = 0 to m exclusive
        declare p, q as integers
        read p and q
        if isgro[p] is true
            declare integer x
            let x be result of run find(q)
            if father[ run find(q) ] is not father[ run find(p) ]
                let father[ run find(q) ] be father [ run find(p) ]
                increment fathercnt[ run find(p) ] by fathercnt[x]
                let fathercnt[x] be 0
            end of the block
        else if isgro[q] is true
            declare integer x
            let x be result of run find(p)
            if father[ run find(p) ] is not father[ run find(q) ]
                let father[ run find(p) ] be father [ run find(q) ]
                increment fathercnt[ run find(q) ] by fathercnt[x]
                let fathercnt[x] be 0
            end of the block
        else
            declare integer x
            if isgro[father[result of run find(p)]] is true
                let x be result of run find(q)
                if father[ run find(q) ] is not father[ run find(p) ]
                    let father[ run find(q) ] be father [ run find(p) ]
                    increment fathercnt[ run find(p) ] by fathercnt[x]
                    let fathercnt[x] be 0
                end of the block
            else
                let x be result of run find(p)
                if father[ run find(p) ] is not father[ run find(q) ]
                    let father[ run find(p) ] be father [ run find(q) ]
                    increment fathercnt[ run find(q) ] by fathercnt[x]
                    let fathercnt[x] be 0
                end of the block
            end of the block
        end of the block
    end of the block
    declare integer maxfather = 0
    declare integer strunity
    for i = 1 to n inclusive
        if fathercnt[i] is greater than maxfather
            let maxfather be fathercnt[i]
            let strunity be i
        end of the block
    end of the block
    declare integer maxgro = 0
    declare integer strgro = gro
    for i = 1 to n inclusive
        if isgro[i] and fathercnt[i] is greater than maxgro
            let maxgro be fathercnt[i]
            let strgro be i
        end of the block
    end of the block
    for i = 1 to n inclusive
        if fathercnt[i] is not 0
            if isgro[run find(i)] is not 1
                increment fathercnt[strgro] by fathercnt[i]
                let fathercnt[i] be 0
            end of the block
        end of the block
    end of the block
    let cnt be 0
    for i = 1 to n inclusive
        if isgro[i] is true, increment cnt by fathercnt[i] * (fathercnt[i] - 1)) / 2
    end of the block
    print cnt - m, newline
    return to indicate successful execution
end of the block

[CODE]:

int father[1005];
int n, m, k;
int find(int x) {
    return father[x] == x ? x : father[x] = find(father[x]);
}
int node[1005];
int fathercnt[1005];
int cnt;
int isgro[1005];
int main() {
    memset(isgro, 0, sizeof(isgro));
    cin >> n >> m >> k;
    int gro;
    for (int j = 1; j <= n; j++) { father[j] = j; }
    for (int i = 0; i < k; i++) {
        int g;
        cin >> g;
        isgro[g] = 1;
        gro = g;
    }
    for (int j = 1; j <= n; j++) { fathercnt[j] = 1; }
    for (int i = 0; i < m; i++) {
        int p, q;
        cin >> p >> q;
        if (isgro[p]) {
            int x;
            x = find(q);
            if (father[find(q)] != father[find(p)]) {
                father[find(q)] = father[find(p)];
                fathercnt[find(p)] += fathercnt[x];
                fathercnt[x] = 0;
            }
        } else if (isgro[q]) {
            int x;
            x = find(p);
            if (father[find(p)] != father[find(q)]) {
                father[find(p)] = father[find(q)];
                fathercnt[find(q)] += fathercnt[x];
                fathercnt[x] = 0;
            }
        } else {
            int x;
            if (isgro[father[find(p)]]) {
                x = find(q);
                if (father[find(q)] != father[find(p)]) {
                    father[find(q)] = father[find(p)];
                    fathercnt[find(p)] += fathercnt[x];
                    fathercnt[x] = 0;
                }
            } else {
                x = find(p);
                if (father[find(p)] != father[find(q)]) {
                    father[find(p)] = father[find(q)];
                    fathercnt[find(q)] += fathercnt[x];
                    fathercnt[x] = 0;
                }
            }
        }
    }
    int maxfather = 0;
    int strunity;
    for (int i = 1; i <= n; i++) {
        if (fathercnt[i] > maxfather) {
            maxfather = fathercnt[i];
            strunity = i;
        }
    }
    int maxgro = 0;
    int strgro = gro;
    for (int i = 1; i <= n; i++) {
        if (isgro[i] && fathercnt[i] > maxgro) {
            maxgro = fathercnt[i];
            strgro = i;
        }
    }
    for (int i = 1; i <= n; i++) {
        if (fathercnt[i] != 0) {
            if (isgro[find(i)] != 1) {
                fathercnt[strgro] += fathercnt[i];
                fathercnt[i] = 0;
            }
        }
    }
    cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (isgro[i]) { cnt += (fathercnt[i] * (fathercnt[i] - 1)) / 2; }
    }
    cout << cnt - m << endl;
    return 0;
}