B - Permutation Check 解説 /

実行時間制限: 2 sec / メモリ制限: 1024 MB

配点 : 200

問題文

1 以上 N 以下の整数からなる長さ N の数列 A = (A_1, A_2, \dots, A_N) が与えられます。

A (1, 2, \dots, N) の並び替えによって得られるかどうか判定してください。

制約

  • 1 \leq N \leq 10^3
  • 1 \leq A_i \leq N
  • 入力は全て整数である。

入力

入力は以下の形式で標準入力から与えられる。

N
A_1 A_2 \ldots A_N

出力

A (1, 2, \dots, N) の並び替えによって得られるなら Yes、そうでないなら No と出力せよ。


入力例 1

5
3 1 2 4 5

出力例 1

Yes

(3, 1, 2, 4, 5)(1, 2, 3, 4, 5) を並び替えて得られるため、Yes と出力します。


入力例 2

6
3 1 4 1 5 2

出力例 2

No

(1, 2, 3, 4, 5, 6) をどのように並び替えても (3, 1, 4, 1, 5, 2) にすることはできないので、No と出力します。


入力例 3

3
1 2 3

出力例 3

Yes

入力例 4

1
1

出力例 4

Yes

Score : 200 points

Problem Statement

You are given a sequence of N integers between 1 and N (inclusive): A = (A_1, A_2, \dots, A_N).

Determine whether A is a permutation of (1, 2, \dots, N).

Constraints

  • 1 \leq N \leq 10^3
  • 1 \leq A_i \leq N
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 \ldots A_N

Output

If A is a permutation of (1, 2, \dots, N), print Yes; otherwise, print No.


Sample Input 1

5
3 1 2 4 5

Sample Output 1

Yes

(3, 1, 2, 4, 5) is a permutation of (1, 2, 3, 4, 5), so we should print Yes.


Sample Input 2

6
3 1 4 1 5 2

Sample Output 2

No

(3, 1, 4, 1, 5, 2) is not a permutation of (1, 2, 3, 4, 5, 6), so we should print No.


Sample Input 3

3
1 2 3

Sample Output 3

Yes

Sample Input 4

1
1

Sample Output 4

Yes