#K45767. Perfect Jigsaw Puzzle

    ID: 27827 Type: Default 1000ms 256MiB

Perfect Jigsaw Puzzle

Perfect Jigsaw Puzzle

You are given an integer \(n\) and a sequence of \(n\) integers representing the pieces of a jigsaw puzzle. A perfect jigsaw puzzle is one where each piece is unique and appears exactly once, meaning the pieces form the consecutive sequence \(\{1, 2, \ldots, n\}\). Your task is to determine whether the given collection of pieces can form a perfect jigsaw puzzle.

If the pieces are exactly the set \(\{1,2,...,n\}\) without any repetition or missing numbers, output YES. Otherwise, output NO.

inputFormat

The input is read from stdin and consists of two lines:

  • The first line contains a single integer \(n\) representing the number of jigsaw puzzle pieces.
  • The second line contains \(n\) space-separated integers representing the puzzle pieces.

outputFormat

Output a single line to stdout containing YES if the pieces form a perfect jigsaw puzzle; otherwise, output NO.

## sample
4
1 2 3 4
YES