All problems

Problem 102

Contains Duplicate

Easy · 10 pts · Array, Hash Table, Sorting

Problem

You are given an array of N integers. Decide whether any value appears at least twice. Print YES if some value repeats, and NO if all values are distinct. Add the values to a hash set one by one; if a value is already in the set, you have found a duplicate. Sorting the array and comparing neighbours also works.

Input

First line: integer N. Second line: N space-separated integers.

Output

Print YES if some value repeats, otherwise NO.

Constraints

1 <= N <= 100000; -1000000000 <= A[i] <= 1000000000

Example input

4
1 2 3 1

Example output

YES

Explanation

In 1 2 3 1, the value 1 appears at index 0 and again at index 3, so the answer is YES.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Intersection of Two Arrays Next: Contains Nearby Duplicate