import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
import std.ascii;

void main() {
    int n;
    scan(n);

    auto adj = new int[][](n, 0);

    foreach (i ; 1 .. n) {
        int pi;
        scan(pi);
        adj[pi-1] ~= i;
    }

    bool ans = true;

    void dfs(int v, int p) {
        if (adj[v].empty) return;

        int lc;

        foreach (u ; adj[v]) {
            if (u == p) continue;
            if (adj[u].empty) {
                lc++;
            }
            else {
                dfs(u, v);
            }
        }

        if (lc < 3) ans = false;

        return;
    }

    dfs(0,0);

    writeln(ans ? "Yes" : "No");
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}