PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GD0000168. Phá hủy dãy số (Array Destruction)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Phá hủy dãy số (Array Destruction)

Array Destruction

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

You have a multiset of 2n2n positive integers. Choose an initial positive sum xx. Repeat nn times: remove two occurrences whose sum equals the current xx, then replace xx with the larger removed value. Determine whether all elements can be removed, and output the initial sum and the ordered pairs if possible.

Input

The first line contains nn. The second contains exactly 2n2n positive integers.

Output

Print NO if impossible. Otherwise print YES, the initial target sum, and then nn lines, each listing the two values removed at that step.

Subtasks

  • Subtask 1 (20 points): 1≤n≤31\le n\le 3; 1≤ai≤1061\le a_i\le 10^6 for all 1≤i≤2n1\le i\le 2n.
  • Subtask 2 (30 points): 1≤n≤401\le n\le 40; 1≤ai≤1061\le a_i\le 10^6 for all 1≤i≤2n1\le i\le 2n.
  • Subtask 3 (50 points): 1≤n≤10001\le n\le 1000; 1≤ai≤1061\le a_i\le 10^6 for all 1≤i≤2n1\le i\le 2n.

Examples

Input

2
3 5 1 2

Output

YES
6
5 1
3 2

Explanation

Start with x=6x=6. Remove (5,1)(5,1), whose sum is 66, then update xx to 55. Remove (3,2)(3,2), whose sum is 55, leaving the multiset empty. Thus the construction is valid.