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

#GD0000156. Hai dãy bị xáo trộn (Two Shuffled Sequences)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Hai dãy bị xáo trộn (Two Shuffled Sequences)

Two Shuffled Sequences

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Two integer sequences existed before their elements were merged and shuffled: the first was strictly increasing and the second strictly decreasing. Empty or single-element sequences are allowed. Given the shuffled sequence aa of nn integers, recover any two sequences with exactly the same combined multiset of values, or report that it is impossible.

Input

The first line contains nn. The second line contains exactly nn integers a1,a2,…,ana_1,a_2,\ldots,a_n.

Output

Print NO if impossible. Otherwise print YES, then the length and elements of the strictly increasing sequence, followed by the length and elements of the strictly decreasing sequence. The elements of an empty sequence may be represented by a blank line.

Subtasks

  • Subtask 1 (20 points): 1≤n≤81\le n\le 8; 0≤ai≤2⋅1050\le a_i\le 2\cdot10^5.
  • Subtask 2 (30 points): 1≤n≤30001\le n\le 3000; 0≤ai≤2⋅1050\le a_i\le 2\cdot10^5.
  • Subtask 3 (50 points): 1≤n≤2⋅1051\le n\le 2\cdot10^5; 0≤ai≤2⋅1050\le a_i\le 2\cdot10^5.

Examples

Input

7
7 2 7 3 3 1 4

Output

YES
5
1 2 3 4 7 
2
7 3

Explanation

The values 33 and 77 appear twice; 1,2,41,2,4 each appear once. The increasing sequence [1,2,3,4,7][1,2,3,4,7] takes one of each value, and [7,3][7,3] takes the remaining copies. Both orders are strict and together contain the seven original values.