P27463 [AtCoder] Mahjong
NOI
题目描述

Problem Description

$ N $ people decided to play mahjong. Mahjong is a table game played by $ 4 $ people.

After a round-robin tournament, each match resulted in one person winning. There were no ties or shared first places. The round-robin tournament among $ N $ people means that when each person is assigned a number from 1 to $ N $, there are $ C(N,4) $ matches where $1 \leq p < q < r < s \leq N$ for four people $ p, q, r, s $.

The ranking table was lost, so the results of each match are unknown.

From the testimony of each person about how many times they won, we decided to check if there exists a match result that satisfies these conditions.

Input Format

The input is given from the standard input in the following format:

$ N $ $ A_1 $ $ A_2 $ $ A_3 $ . . . $ A_N $

  • The first line contains the number of people who played mahjong, $N (4 \leq N \leq 10^{4})$.
  • The next $ N $ lines contain the number of wins for each person. The $ i $-th line contains the number of wins $A_i (0 \leq A_i \leq 10^{12})$ for the $ i $-th person.

Output Format

If there exists a match result where each person's number of wins is correct, output 'YES'. If not, output 'NO'. Ensure to end the output with a newline.

Sample Input and Output

Sample Input #1

4
1
0
0
0

Sample Output #1

YES

Sample Input #2

7
20
10
5
0
0
0
0

Sample Output #2

NO

Notes/Hints

None

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 1 0 0 0
样例输出
YES