Under construction

Still being built. Things may change

Card Game 2

Interview

Time limit2sMemory limit1024 MB

Summary
Given N card values, determine whether some integer x exists such that cards with values x, x+3, and x+6 all appear.
Level

Easy2 of 10

Topics
Array, Hash map
Solved
No attempts yet

문제

Bitaro has NN cards. The ii-th card (1≤i≤N1 \le i \le N) has an integer AiA_i written on it. Bitaro wants to pick three of these cards that satisfy the following condition.

Condition: The integers written on the chosen cards are 3 apart. Precisely, they can be written as x,x+3,x+6x, x+3, x+6 for some integer xx.

Given the cards Bitaro has, write a program that determines whether three cards can be chosen to satisfy the condition.

입력

N
A_1 A_2 \ldots A_N

출력

Print Yes if three cards can be chosen to satisfy the condition, and No otherwise.

제한

  • 3≤N≤200 0003 \le N \le 200\,000.
  • 1≤Ai≤200 0001 \le A_i \le 200\,000 (1≤i≤N1 \le i \le N).
  • All input values are integers.

Examples4

  1. Example 1

    Input
    3
    2 5 8
    
    Expected output
    Yes
    
  2. Example 2

    Input
    4
    1 4 6 4
    
    Expected output
    No
    
  3. Example 3

    Input
    8
    9 8 11 1 1 6 10 4
    
    Expected output
    No
    
  4. Example 4

    Input
    20
    2 15 4 30 6 8 11 27 14 3 16 26 19 2 23 21 18 13 28 6
    
    Expected output
    Yes