Christmas Spruce

题意翻译

### 题目描述 给定一棵树,其中的每个非叶子节点的儿子中,必须有不少于三个节点是叶子节点,满足输出 `YES`,否则输出 `NO`。 ### 输入格式 第一行包含一个整数 $n(3\le n\le 1000)$,表示树的节点数。 接下来的 $n-1$ 行每行包含一个整数 $p_i(1\le p_i\le i)$,$p_i$ 表示第 $i+1$ 号节点的父亲。

题目描述

Consider a rooted tree. A rooted tree has one special vertex called the root. All edges are directed from the root. Vertex $ u $ is called a child of vertex $ v $ and vertex $ v $ is called a parent of vertex $ u $ if there exists a directed edge from $ v $ to $ u $ . A vertex is called a leaf if it doesn't have children and has a parent. Let's call a rooted tree a spruce if its every non-leaf vertex has at least $ 3 $ leaf children. You are given a rooted tree, check whether it's a spruce. The definition of a rooted tree can be found [here](https://goo.gl/1dqvzz).

输入输出格式

输入格式


The first line contains one integer $ n $ — the number of vertices in the tree ( $ 3<=n<=1000 $ ). Each of the next $ n-1 $ lines contains one integer $ p_{i} $ ( $ 1<=i<=n-1 $ ) — the index of the parent of the $ i+1 $ -th vertex ( $ 1<=p_{i}<=i $ ). Vertex $ 1 $ is the root. It's guaranteed that the root has at least $ 2 $ children.

输出格式


Print "Yes" if the tree is a spruce and "No" otherwise.

输入输出样例

输入样例 #1

4
1
1
1

输出样例 #1

Yes

输入样例 #2

7
1
1
1
2
2
2

输出样例 #2

No

输入样例 #3

8
1
1
1
1
3
3
3

输出样例 #3

Yes

说明

The first example: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF913B/3d87b6a6cda0ba6f4ad05908fb42ae8248c8369b.png) The second example: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF913B/bd0b03933e2dbb274b2b58b0c7a13d930c39c80b.png) It is not a spruce, because the non-leaf vertex $ 1 $ has only $ 2 $ leaf children. The third example: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF913B/a9d72240b2a5e338c43541d320aabfb5ee526dff.png)