Two integer sequences existed initially — one of them was strictly increasing, and the other one — strictly decreasing.

Strictly increasing sequence is a sequence of integers $[x_1 < x_2 < \dots < x_k]$. And strictly decreasing sequence is a sequence of integers $[y_1 > y_2 > \dots > y_l]$. Note that the empty sequence and the sequence consisting of one element can be considered as increasing or decreasing.

They were merged into one sequence $a$. After that sequence $a$ got shuffled. For example, some of the possible resulting sequences $a$ for an increasing sequence $[1, 3, 4]$ and a decreasing sequence $[10, 4, 2]$ are sequences $[1, 2, 3, 4, 4, 10]$ or $[4, 2, 1, 10, 4, 3]$.

This shuffled sequence $a$ is given in the input.

Your task is to find any two suitable initial sequences. One of them should be strictly increasing and the other one — strictly decreasing. Note that the empty sequence and the sequence consisting of one element can be considered as increasing or decreasing.

If there is a contradiction in the input and it is impossible to split the given sequence $a$ to increasing and decreasing sequences, print "NO".


-----Input-----

The first line of the input contains one integer $n$ ($1 \le n \le 2 \cdot 10^5$) — the number of elements in $a$.

The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($0 \le a_i \le 2 \cdot 10^5$), where $a_i$ is the $i$-th element of $a$.


-----Output-----

If there is a contradiction in the input and it is impossible to split the given sequence $a$ to increasing and decreasing sequences, print "NO" in the first line.

Otherwise print "YES" in the first line and any two suitable sequences. Note that the empty sequence and the sequence consisting of one element can be considered as increasing or decreasing.

In the second line print $n_i$ — the number of elements in the strictly increasing sequence. $n_i$ can be zero, in this case the increasing sequence is empty.

In the third line print $n_i$ integers $inc_1, inc_2, \dots, inc_{n_i}$ in the increasing order of its values ($inc_1 < inc_2 < \dots < inc_{n_i}$) — the strictly increasing sequence itself. You can keep this line empty if $n_i = 0$ (or just print the empty line).

In the fourth line print $n_d$ — the number of elements in the strictly decreasing sequence. $n_d$ can be zero, in this case the decreasing sequence is empty.

In the fifth line print $n_d$ integers $dec_1, dec_2, \dots, dec_{n_d}$ in the decreasing order of its values ($dec_1 > dec_2 > \dots > dec_{n_d}$) — the strictly decreasing sequence itself. You can keep this line empty if $n_d = 0$ (or just print the empty line).

$n_i + n_d$ should be equal to $n$ and the union of printed sequences should be a permutation of the given sequence (in case of "YES" answer).


-----Examples-----
Input
7
7 2 7 3 3 1 4

Output
YES
2
3 7 
5
7 4 3 2 1 

Input
5
4 3 1 5 3

Output
YES
1
3 
4
5 4 3 1 

Input
5
1 1 2 1 2

Output
NO

Input
5
0 1 2 3 4

Output
YES
0

5
4 3 2 1 0

Difficulty: introductory

Starter code:

Solutions:
n = int(input())
a = list(map(int, input().split()))
a.sort()

inc = list()
dec = list()
for x in a:
    if inc and inc[-1] == x:
        if dec and dec[-1] == x:
            print('NO')
            return
        dec.append(x)
    else:
        inc.append(x)

print('YES')
print(len(inc))
for x in inc:
    print(x, end=' ')
print()
print(len(dec))
for x in reversed(dec):
    print(x, end=' ')
print()

def solve():
    N = int(input())
    
    A = [int(k) for k in input().split()]
    A.sort()
    
    B = [A[0]]
    C = []
    
    cnt = 1
    
    for i in range(1,N):
        if A[i] == A[i-1]:
            cnt += 1
            if cnt > 2:
                print ("NO")
                return
        else:
            cnt = 1
            
        if B[-1] != A[i]:
            B.append(A[i])
        else:
            C.append(A[i])
            
    print ("YES")
    print (len(B))
    print (' '.join(str(k) for k in B))
    print (len(C))
    print (' '.join(str(k) for k in reversed(C)))
        
def __starting_point():
    solve()
__starting_point()

n = int(input())
a = list(map(int, input().split()))
inc = set([])
dec = set([])
for i in a:
    if i not in inc:
        inc.add(i)
    elif i not in dec:
        dec.add(i)
    else:
        print("NO")
        return
inc = list(inc)
dec = list(dec)
inc.sort(reverse = True)
dec.sort()
print("YES")
print(len(dec))
print(*dec)
print(len(inc))
print(*inc)

#Bhargey Mehta (Sophomore)
#DA-IICT, Gandhinagar
import sys, math, queue
sys.setrecursionlimit(1000000)
#sys.stdin = open("input.txt", "r")

n = int(input())
a = list(map(int, input().split()))
inc = set()
dec = set()

for ai in a:
    if ai not in inc:
        inc.add(ai)
    elif ai not in dec:
        dec.add(ai)
    else:
        print("NO")
        return

inc = sorted(inc)
dec = sorted(dec, reverse=True)
print("YES")
print(len(inc))
print(*inc)
print(len(dec))
print(*dec)


n = int(input())
A = list(map(int, input().split()))

B = set()
C = set()
yes = True

for i in A:
    if i not in B:
        B.add(i)
    elif i not in C:
        C.add(i)
    else:
        print('NO')
        yes = False
        break

if yes:
    print('YES')

    print(len(B))
    print(*sorted(list(B)))

    print(len(C))
    print(*sorted(list(C), reverse=True))


import sys

n=int(input())
A=list(map(int,input().split()))
A.sort()

ANS0=[A[0]]
ANS1=[]
for i in range(1,n):
    if A[i]==ANS0[-1]:
        ANS1.append(A[i])

    else:
        ANS0.append(A[i])

for i in range(1,len(ANS1)):
    if ANS1[i]==ANS1[i-1]:
        print("NO")
        return

print("YES")
print(len(ANS0))
print(*ANS0)
print(len(ANS1))
print(*ANS1[::-1])
    


from collections import defaultdict
n = int(input())
a = list(map(int,input().split()))
l1 = []
l2 = []
da = defaultdict(int)
db = defaultdict(int)
work = True
for i in a:
    if da[i]==0:
        l1.append(i)
        da[i] = 1
    elif db[i]==0:
        l2.append(i)
        db[i] = 1
    else:
        work = False

if work:
    print("YES")
    print(len(l1))
    print(*sorted(l1))
    print(len(l2))
    l2 = sorted(l2)
    l2 = l2[::-1]
    print(*l2)
else:
    print("NO")

import sys

n = int(input())
a = [int(x) for x in input().split()]
d = {}
for x in a:
    c = d.get(x, 0) + 1
    if c == 3:
        print('NO')
        return
    d[x] = c

r1 = []
r2 = []
for key, value in d.items():
    r1.append(key)
    if value > 1: r2.append(key)

r1.sort()
r2.sort(reverse=True)

print('YES')
print(len(r1))
for x in r1:
    print(x, end=' ')
print()
print(len(r2))
for x in r2:
    print(x, end=' ')


''' CODED WITH LOVE BY SATYAM KUMAR '''

from sys import stdin, stdout
import cProfile, math
from collections import Counter,defaultdict
from bisect import bisect_left,bisect,bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
import operator as op
from functools import reduce
sys.setrecursionlimit(10**6) # max depth of recursion
threading.stack_size(2**27)  # new thread will get stack of such size
fac_warmup = False
printHeap = str()
memory_constrained = False
P = 10**9+7
import sys

class merge_find:
    def __init__(self,n):
        self.parent = list(range(n))
        self.size = [1]*n
        self.num_sets = n
        self.lista = [[_] for _ in range(n)]
    def find(self,a):
        to_update = []
        while a != self.parent[a]:
            to_update.append(a)
            a = self.parent[a]
        for b in to_update:
            self.parent[b] = a
        return self.parent[a]
    def merge(self,a,b):
        a = self.find(a)
        b = self.find(b)
        if a==b:
            return
        if self.size[a]<self.size[b]:
            a,b = b,a
        self.num_sets -= 1
        self.parent[b] = a
        self.size[a] += self.size[b]
        self.lista[a] += self.lista[b]
    def set_size(self, a):
        return self.size[self.find(a)]
    def __len__(self):
        return self.num_sets

def display(string_to_print):
    stdout.write(str(string_to_print) + "\n")

def primeFactors(n): #n**0.5 complex 
    factors = dict()
    for i in range(2,math.ceil(math.sqrt(n))+1):  
        while n % i== 0: 
            if i in factors:
                factors[i]+=1
            else: factors[i]=1
            n = n // i 
    if n>2:
        factors[n]=1
    return (factors)

def fibonacci_modP(n,MOD):
    if n<2: return 1
    #print (n,MOD)
    return (cached_fn(fibonacci_modP, (n+1)//2, MOD)*cached_fn(fibonacci_modP, n//2, MOD) + cached_fn(fibonacci_modP, (n-1) // 2, MOD)*cached_fn(fibonacci_modP, (n-2) // 2, MOD)) % MOD

def factorial_modP_Wilson(n , p): 
    if (p <= n): 
        return 0
    res = (p - 1) 
    for i in range (n + 1, p): 
        res = (res * cached_fn(InverseEuler,i, p)) % p 
    return res 

def binary(n,digits = 20):
    b = bin(n)[2:]
    b = '0'*(20-len(b))+b
    return b

def isprime(n):
    """Returns True if n is prime."""
    if n < 4:
        return True
    if n % 2 == 0:
        return False
    if n % 3 == 0:
        return False
    i = 5
    w = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += w
        w = 6 - w
    return True
factorial_modP = []
def warm_up_fac(MOD):
    nonlocal factorial_modP,fac_warmup
    if fac_warmup: return
    factorial_modP= [1 for _ in range(fac_warmup_size+1)]
    for i in range(2,fac_warmup_size):
        factorial_modP[i]= (factorial_modP[i-1]*i) % MOD
    fac_warmup = True

def InverseEuler(n,MOD):
    return pow(n,MOD-2,MOD)

def nCr(n, r, MOD):
    nonlocal fac_warmup,factorial_modP
    if not fac_warmup:
        warm_up_fac(MOD)
        fac_warmup = True
    return (factorial_modP[n]*((pow(factorial_modP[r], MOD-2, MOD) * pow(factorial_modP[n-r], MOD-2, MOD)) % MOD)) % MOD

def test_print(*args):
    if testingMode:
        print(args)

def display_list(list1, sep=" "):
    stdout.write(sep.join(map(str, list1)) + "\n")

def display_2D_list(li):
    for i in li:
        print(i)
def prefix_sum(li):
    sm = 0
    res = []
    for i in li:
        sm+=i
        res.append(sm)
    return res

def get_int():
    return int(stdin.readline().strip())

def get_tuple():
    return map(int, stdin.readline().split())

def get_list():
    return list(map(int, stdin.readline().split()))
import heapq,itertools
pq = []                         # list of entries arranged in a heap
entry_finder = {}               # mapping of tasks to entries
REMOVED = '<removed-task>' 
def add_task(task, priority=0):
    'Add a new task or update the priority of an existing task'
    if task in entry_finder:
        remove_task(task)
    count = next(counter)
    entry = [priority, count, task]
    entry_finder[task] = entry
    heapq.heappush(pq, entry)

def remove_task(task):
    'Mark an existing task as REMOVED.  Raise KeyError if not found.'
    entry = entry_finder.pop(task)
    entry[-1] = REMOVED

def pop_task():
    'Remove and return the lowest priority task. Raise KeyError if empty.'
    while pq:
        priority, count, task = heapq.heappop(pq)
        if task is not REMOVED:
            del entry_finder[task]
            return task
    raise KeyError('pop from an empty priority queue')
memory = dict()
def clear_cache():
    nonlocal memory
    memory = dict()
def cached_fn(fn, *args):
    nonlocal memory
    if args in memory:
        return memory[args]
    else:
        result = fn(*args)
        memory[args] = result
        return result

def ncr (n,r):
    return math.factorial(n)/(math.factorial(n-r)*math.factorial(r))
def binary_serach(i,li):
    #print("Search for ",i)
    fn = lambda x: li[x]-x//i
    x = -1
    b = len(li)
    while b>=1:
        #print(b,x)
        while b+x<len(li) and fn(b+x)>0: #Change this condition 2 to whatever you like
            x+=b
        b=b//2
    return x

# -------------------------------------------------------------- MAIN PROGRAM
TestCases = False
testingMode = False
fac_warmup_size = 10**5+100
optimiseForReccursion = True #Can not be used clubbed with TestCases # WHen using recursive functions, use Python 3
from math import factorial


def main():
    n = get_int()
    li = get_list()
    li.sort()
    prev = -2
    a,b = [],[]
    for i in li:
        if i!=prev:
            a.append(i)
        else:
            b.append(i)
        prev = i
    if len(set(b))!=len(b):
        print("NO")
        return
    print("YES")
    print(len(a))
    display_list(a)
    print(len(b))
    b.reverse()
    display_list(b)
    
# --------------------------------------------------------------------- END=


if TestCases: 
    for _ in range(get_int()): 
        cProfile.run('main()') if testingMode else main() 
else: (cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()

N = int(input())
A = sorted([int(a) for a in input().split()])

pre = -1
c = 0
I = []
D = []
for i in range(N):
    if A[i] == pre:
        c += 1
        if c > 2:
            print("NO")
            break
        D.append(A[i])
    else:
        I.append(A[i])
        pre = A[i]
        c = 1
else:
    print("YES")
    print(len(I))
    print(*I)
    print(len(D))
    print(*sorted(D)[::-1])


from bisect import bisect_right as br
from bisect import bisect_left as bl
from collections import *
from itertools import *
import functools
import sys
import math
import random
MAX = sys.maxsize
MAXN = 10**5+10
MOD = 10**9+7
def isprime(n):
    n = abs(int(n))
    if n < 2:
        return False
    if n == 2: 
        return True    
    if not n & 1: 
        return False
    for x in range(3, int(n**0.5) + 1, 2):
        if n % x == 0:
            return False
    return True

def mhd(a,b,x,y):
    return abs(a-x)+abs(b-y)

def numIN(x = " "):
    return(map(int,sys.stdin.readline().strip().split(x)))

def charIN():
    return(sys.stdin.readline().strip().split())

def dis(x,y):
    a = y[0]-x[0]
    b = x[1]-y[1]
    return (a*a+b*b)**0.5




n = int(input())
l = list(numIN())
d = defaultdict(int)

for i in l:
    d[i]+=1
    if d[i]>2:
        print('NO')
        return

l.sort()
ans1 = []
ans2 = []
for i in l:
    if d[i]==2:
        ans1.append(i)
        ans2.append(i)
        d[i] = 0
    elif d[i]==1:
        ans1.append(i)
        d[i] = 0
ans1.sort()
ans2.sort(reverse=True)

print('YES')
print(len(ans1))
print(*ans1)
print(len(ans2))
print(*ans2)

import sys

input = sys.stdin.readline

n = int(input())

a = sorted(map(int, input().split()))

up = [a[0]]
a[0] = -1

for i in range(len(a)):
    if a[i] != -1 and a[i] > up[-1]:
        up.append(a[i])
        a[i] = -1
    
down = sorted([x for x in a if x != -1], reverse = True)

valid = True
for i in range(1, len(down)):
    if down[i] == down[i-1]:
        valid = False
        break

if valid:
    print('YES')
    print(len(up))
    print(' '.join([str(x) for x in up]))
    print(len(down))
    print(' '.join([str(x) for x in down]))
else:
    print('NO')


'''input
5
0 1 2 3 
'''
import sys
from collections import defaultdict as dd
from itertools import  permutations as pp
from itertools import combinations as cc
from collections import Counter as ccd
from random import randint as rd
from bisect import bisect_left as bl
import heapq
mod=10**9+7

def ri(flag=0):
	if flag==0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())

n=ri(1)

a=ri()

a.sort()

k=dd(int)

for i in a:
	k[i]+=1

f=1
for i in k:
	if k[i]>2:
		f=0

one=[]
two=[]

for i in k:
	if k[i]==1:
		one.append(i)

	elif k[i]==2:
		one.append(i)
		two.append(i)

if f:
	print("YES")
	print(len(one))
	one.sort()
	print(*one)
	print(len(two))
	two.sort(reverse=True)
	print(*two)
else:
	print("NO")

from collections import Counter

n = int(input())
arr = list(map(int, input().split()))
arr.sort()

C = Counter(arr)
flag = 0

for keys in C:
    if C[keys]>=3:
        flag = 1
        print("NO")
        break

if flag==0:
    print("YES")
    es = []
    ds = []
    for keys in C:
        if C[keys]==2:
            es.append(keys)
            ds.append(keys)
        else:
            es.append(keys)

    es.sort()
    ds.sort()
    ds = ds[::-1]

    print(len(es))
    print(*es)
    print(len(ds))
    print(*ds)


# -*- coding: utf-8 -*-


def __starting_point():
    _ = int(input())

    array = sorted(list(map(int, input().split())))
    inc = []
    dec = []
    for elem in array:
        if elem in inc[-1:] and elem in dec[-1:]:
            inc = None
            dec = None
            break;

        if elem in inc[-1:]:
            dec.append(elem)
        else:
            inc.append(elem)

    if inc is None:
        print("NO")
    else:
        print("YES")
        print(len(inc))
        print(" ".join(str(e) for e in inc))
        print(len(dec))
        print(" ".join(str(e) for e in dec[::-1]))

__starting_point()

n = int(input())

one = set()
two = set()
ban = 0
for i in input().split():
    i = int(i)
    if i not in one:
        one.add(i)
    else:
        if i not in two:
            two.add(i)
        else:
            ban = 1
            break

if ban:
    print('NO')
else:
    print('YES')
    one = list(one)
    print(len(one))
    one.sort()
    for i in one:
        print(i, end=' ')
    print()

    two = list(two)
    print(len(two))
    two.sort(reverse=True)
    for i in two:
        print(i, end=' ')
    print()

from collections import Counter
n = int(input())
l = list(map(int,input().split()))

d = Counter(l)

if max(d.values()) > 2:
    print("NO")
else:
    inc = []
    dec = []

    for i in d:
        if d[i] == 2:
            inc.append(i)
            dec.append(i)
        else:
            inc.append(i)


    n1 = len(inc)
    n2 = len(dec)
    print("YES")
    if n1:
        print(n1)
        inc.sort()
        print(*inc)
    else:
        print(n1)
        print()

    if n2:
        print(n2)
        dec.sort(reverse = True)
        print(*dec)
    else:
        print(n2)
        print()


n=int(input())
l=[int(i) for i in input().split()]
l.sort()
from collections import Counter 
c=Counter(l)
if any(c[i]>2 for i in c):
    print('NO')
    return
seq1=[]
seq2=[]
for i in sorted(set(l)):
    if c[i]==1:
        seq1.append(i)
    else:
        seq1.append(i)
        seq2.append(i)
print('YES')
print(len(seq1))
print(*seq1)
print(len(seq2))
seq2=seq2[::-1]
print(*seq2)


import math
def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return n,b


def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return n,b,c


def dv():
	n, m = list(map(int, input().split()))
	return n,m


def dva():
	n, m = list(map(int, input().split()))
	b = [int(x) for x in input().split()]
	return n,m,b


def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return n,b,m,c


def dvs():
	n = int(input())
	m = int(input())
	return n, m


n,a = na()
d = {}
for i in a:
	d[i] = d.get(i, 0) + 1
ls = list(d.keys())
for i in ls:
	if d[i] > 2:
		print('NO')
		return
a1 = []
a2 = []
a = sorted(a)
for i in range(0, n - 1, 2):
	if len(a1) != 0:
		lst1 = a1[len(a1) - 1]
	else:
		lst1 = -1
	if len(a2) != 0:
		lst2 = a2[len(a2) - 1]
	else:
		lst2 = -1
	if a[i] != lst1:
		if a[i] != a[i + 1]:
			a1.append(a[i])
			a1.append(a[i + 1])
		else:
			a1.append(a[i])
			a2.append(a[i + 1])
	else:
		a1.append(a[i + 1])
		a2.append(a[i])
if n % 2 == 1:
	if a[n - 1] not in set(a1):
		a1.append(a[n-1])
	else:
		a2.append(a[n - 1])
a2 = a2[::-1]
print('YES')
print(len(a1))
if len(a1) == 0:
	print()
else:
	print(*a1)
print(len(a2))
if len(a2) == 0:
	print()
else:
	print(*a2)



n = int(input())
a = list(map(int,input().split()))
f = [0 for i in range(200010)]
inc = []
dec = []
for i in a:
    if f[i]==0:
        inc.append(i)
        f[i]+=1
    elif f[i]==1:
        dec.append(i)
        f[i]+=1
    elif f[i]>1:
        print("NO")
        return
print("YES")
print(len(inc))
print(*(sorted(inc)))
print(len(dec))
print(*(sorted(dec,reverse=True)))