#C2877. Equilateral Triangle Formation
Equilateral Triangle Formation
Equilateral Triangle Formation
You are given n matchsticks and their respective lengths. Your task is to determine whether it is possible to select three matchsticks of the same length to form an equilateral triangle. In mathematical terms, if there exists a length \( L \) such that at least three matchsticks have length \( L \), then an equilateral triangle can be formed.
If such a set of three matchsticks exists, output YES
; otherwise, output NO
.
Note: The input is provided via standard input (stdin) and the output should be printed to standard output (stdout).
inputFormat
The input consists of two lines:
- The first line contains an integer
n
representing the total number of matchsticks. - The second line contains
n
space-separated integers representing the lengths of the matchsticks.
You can assume that n \geq 3
.
outputFormat
Output a single line containing YES
if it is possible to form an equilateral triangle using any three matchsticks; otherwise, output NO
.
6
1 1 1 2 3 4
YES
</p>