Problem5195--Permutation Check

5195: Permutation Check

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 256 MiB

Description

Check whether array A is a permutation.
A permutation is a sequence containing each element from 1 to N once, and only once.
For example, array A such that:
A[0] = 4
A[1] = 1
A[2] = 3
A[3] = 2
is a permutation, but array A such that:
A[0] = 4
A[1] = 1
A[2] = 3
is not a permutation, because value 2 is missing.
The goal is to check whether array A is a permutation. 

Input

Two lines.
The first line is N. N is an integer within the range [1..100,000];
The second line has N elements. each element of array is an integer within the range [1..1,000,000,000].

Output

returns 1 if array A is a permutation and 0 if it is not.

Sample 1 Input

4
4 1 3 2

Sample 1 Output

1

Source/Category