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

Source: codeforces | Difficulty: EASY
Tags: Sorting

Constructive algorithms


Solutions:
import sys
from collections import Counter

def get_ints():
	return list(map(int, sys.stdin.readline().strip().split()))

def solve():
	n = int(input())
	arr = get_ints()
	arr.sort()
	if n == 1:
		print('YES')
		print(1)
		print(arr[0])
		print(0)
		return
	c1 = Counter(arr)
	if max(c1.values()) > 2:
		print('NO')
		return
	inc = arr[::2]
	dec = arr[1::2]
	print('YES')
	print(len(inc))
	print(*inc)
	print(len(dec))
	print(*dec[::-1])
solve()


def solve(n, a):
	inc = [a[0]]
	dec = []
	for i in range(1, n):
		if a[i] == a[i - 1]:
			dec.append(a[i])
			if len(dec) >= 2 and dec[-1] == dec[-2]:
				return 'NO'
		else:
			inc.append(a[i])
			if len(inc) >= 2 and inc[-1] == inc[-2]:
				return 'NO'
	return (inc, dec)
n = int(input())
a = sorted(list(map(int, input().split())))
p = solve(n, a)
if p == 'NO':
	print(p)
else:
	print('YES')
	print(len(p[0]))
	print(*p[0])
	print(len(p[1]))
	print(*p[1][::-1])


from collections import defaultdict, deque
n = int(input())
a = list(map(int, input().split()))
counts = defaultdict(int)
i = set()
d = set()
for x in a:
	if x in d:
		print('NO')
		exit()
	elif x in i:
		d.add(x)
	else:
		i.add(x)
print('YES')
print(len(i))
print(*sorted(i))
print(len(d))
print(*sorted(d, reverse=True))


def ii():
	return int(input())

def fi():
	return float(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
n = ii()
a = li()
s1 = set()
s2 = set()
for i in a:
	if i not in s1:
		s1.add(i)
	elif i not in s2:
		s2.add(i)
	else:
		print('NO')
		exit()
print('YES')
print(len(s2))
print(' '.join([str(x) for x in sorted(s2)]))
print(len(s1))
print(' '.join([str(x) for x in sorted(s1, reverse=True)]))


n = int(input())
data = list(map(int, input().split())) + [0]
(ans, inc, dec) = ([0] * n, -1, 10000000.0)
for i in range(n):
	if inc < data[i] < dec:
		if data[i] < data[i + 1]:
			inc = data[i]
		else:
			dec = data[i]
			ans[i] = 1
	elif inc < data[i]:
		inc = data[i]
	elif dec > data[i]:
		dec = data[i]
		ans[i] = 1
	else:
		print('NO')
		break
else:
	print('YES')
	print(*ans)


def listToString(a):
	a = list(map(str, a))
	return ' '.join(a)
n = int(input())
a = list(map(int, input().split()))
inc = []
dec = []
a.sort()
for i in range(n):
	if i & 1:
		dec.append(a[i])
	else:
		inc.append(a[i])
len_inc = len(inc)
len_dec = len(dec)
if len_inc != len(set(inc)) or len_dec != len(set(dec)):
	print('NO')
else:
	print('YES')
	print(len_inc)
	print(listToString(inc))
	print(len_dec)
	print(listToString(dec[::-1]))


n = int(input())
num = [int(x) for x in input().split(' ')]
num.sort()
f = 0
b = []
a = [num[0]]
c = 0
for i in range(1, n):
	if num[i - 1] < num[i]:
		a.append(num[i])
	else:
		b.append(num[i])
		c += 1
b.sort(reverse=True)
for i in range(1, c):
	if b[i] == b[i - 1]:
		f = 1
		break
if f == 1:
	print('NO')
else:
	print('YES')
	print(len(a))
	for elem in a:
		print(elem, end=' ')
	print()
	print(len(b))
	for elem in b:
		print(elem, end=' ')


import sys

def Ints():
	return map(int, sys.stdin.readline().strip().split())

def Strs():
	return map(str, sys.stdin.readline().strip().split())

def Array():
	return list(map(int, sys.stdin.readline().strip().split()))

def Str():
	return sys.stdin.readline().strip()

def Int():
	return int(sys.stdin.readline().strip())

def MOD():
	return 1000000007

def power(base, power):
	MOD = 1000000007
	result = 1
	while power > 0:
		if power % 2 == 1:
			result = result * base % MOD
		power = power // 2
		base = base * base % MOD
	return result
n = Int()
a = Array()
(sin, sde) = (set(), set())
(increase, decrease) = ([], [])
status = 'YES'
for i in range(n):
	if a[i] not in sin:
		sin.add(a[i])
		increase.append(a[i])
	elif a[i] not in sde:
		sde.add(a[i])
		decrease.append(a[i])
	else:
		status = 'NO'
if status == 'YES':
	increase = sorted(increase)
	decrease = sorted(decrease, reverse=True)
	print(status)
	print(len(increase))
	for i in increase:
		print(i, end=' ')
	print()
	print(len(decrease))
	for i in decrease:
		print(i, end=' ')
else:
	print(status)


n = int(input())
l = [int(i) for i in input().split(' ')]
l.sort()
a = []
b = []
(x1, x2) = (None, None)
for x in l:
	if x == x1 and x == x2:
		print('NO')
		break
	if x == x1:
		b.append(x)
	else:
		a.append(x)
	x2 = x1
	x1 = x
else:
	b.reverse()
	print('YES')
	print(len(a))
	print(' '.join([str(i) for i in a]))
	print(len(b))
	print(' '.join([str(i) for i in b]))


n = int(input())
a = sorted(map(int, input().split()))
(j, k, a1, a2) = (-1, -1, sorted(set(a)), [])
for i in a:
	if i == j == k:
		print('NO')
		exit()
	elif i == j:
		a2.append(i)
	(j, k) = (i, j)
print('YES')
print(len(a1), *a1)
print(len(a2), *reversed(a2))


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')


n = int(input())
a = sorted([int(i) for i in input().split()])
k = 0
b = []
c = []
if n == 1:
	print('YES')
	print(1)
	print(a[0])
	print(0)
	print()
elif n == 2:
	print('YES')
	print(1)
	print(a[0])
	print(1)
	print(a[1])
else:
	i = 0
	while i < n:
		if i < n - 2 and a[i] == a[i + 1] and (a[i] == a[i + 2]):
			k = -1
			break
		elif i < n - 1 and a[i] == a[i + 1]:
			b.append(a[i])
			c.append(a[i])
			i += 2
		else:
			b.append(a[i])
			i += 1
	if k != -1:
		print('YES')
		print(len(b))
		for i in range(len(b)):
			if i != len(b) - 1:
				print(b[i], end=' ')
			else:
				print(b[i], end='\n')
		print(len(c))
		for i in range(len(c)):
			print(c[len(c) - i - 1], end=' ')
	else:
		print('NO')


n = int(input())
l = list(map(int, input().split()))
c = {i: 0 for i in range(200001)}
for x in l:
	c[x] += 1
	if c[x] > 2:
		print('No')
		exit()
a = []
b = []
for i in range(200001):
	if c[i] == 2:
		b.append(i)
		a.append(i)
	elif c[i] == 1:
		a.append(i)
a.sort()
b.sort(reverse=True)
print('Yes')
print(len(a))
print(*a)
print(len(b))
print(*b)


import sys
import os

def main(args):
	states = []
	queue = [(min(args) - 1, max(args) + 1, None, None)]
	answer_flag = True
	for i in range(len(args)):
		x = args[i]
		h_queue = []
		l_queue = []
		for j in range(len(queue)):
			if queue[j][1] is None or x < queue[j][1]:
				l_queue.append((queue[j][0], x, 1, j))
			else:
				break
		for j in range(len(queue) - 1, -1, -1):
			if queue[j][0] is None or x > queue[j][0]:
				h_queue.append((x, queue[j][1], 0, j))
			else:
				break
		queue = []
		if len(h_queue) > 0:
			queue.append(h_queue[-1])
		if len(l_queue) > 0:
			queue.append(l_queue[-1])
		if len(queue) > 1:
			if queue[0][0] < queue[1][0]:
				t = queue[0]
				queue[0] = queue[1]
				queue[1] = t
		if len(queue) == 0:
			answer_flag = False
			break
		states.append(queue)
	if answer_flag:
		print('YES')
	else:
		print('NO')
	if answer_flag:
		p = 0
		result = [None for i in range(len(states))]
		for i in range(len(states) - 1, -1, -1):
			result[i] = states[i][p][2]
			p = states[i][p][3]
		print(' '.join(map(str, result)))
input()
args = list(map(int, input().strip().split()))
main(args)


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
if max(dict(c).values()) > 2:
	print('NO')
else:
	print('YES')
	ind = []
	a.sort()
	for i in range(len(a) - 1):
		if a[i] == a[i + 1]:
			ind.append(i)
	l1 = []
	l2 = []
	switch = True
	prev = -1
	next = 0
	for i in range(len(ind)):
		next = ind[i] + 1
		if switch:
			l1 += a[prev + 1:next]
		else:
			l2 += a[prev + 1:next]
		prev = ind[i]
		switch = not switch
	if switch:
		l1 += a[prev + 1:]
	else:
		l2 += a[prev + 1:]
	l2.reverse()
	print(len(l1))
	print(*l1)
	print(len(l2))
	print(*l2)


def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	s1 = set()
	s2 = set()
	for i in arr:
		if not i in s1:
			s1.add(i)
		elif not i in s2:
			s2.add(i)
		else:
			print('NO')
			return
	print('YES')
	print(len(s1))
	print(*sorted(s1))
	print(len(s2))
	print(*sorted(s2, reverse=True))
solve()


n = int(input())
l = sorted(list(map(int, input().split())))
d = {}
(a, b) = ([], [])
for i in l:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
c = max(d.values())
if c > 2:
	print('NO')
else:
	for i in d:
		if d[i] == 2:
			a.append(i)
			b.append(i)
		else:
			a.append(i)
	print('YES')
	print(len(b))
	print(*b)
	print(len(a))
	print(*a[::-1])


from collections import Counter, defaultdict, deque
import itertools
import string

def solve(m):
	a = []
	b = []
	a.append(m[0])
	for i in range(1, n):
		if m[i] == m[i - 1]:
			if a and a[-1] == m[i] and b and (b[-1] == m[i]):
				return (False, [], [])
		if not a or a[-1] != m[i]:
			a.append(m[i])
		elif not b or b[-1] != m[i]:
			b.append(m[i])
	return (True, a, b)
n = int(input())
m = list(map(int, input().split()))
m.sort()
(flag, a, b) = solve(m)
if not flag:
	print('No')
else:
	print('Yes')
	print(len(a))
	print(' '.join(map(str, a)))
	print(len(b))
	print(' '.join(map(str, sorted(b, reverse=True))))


from sys import setcheckinterval, stdin
setcheckinterval(1000)
iin = lambda : int(stdin.readline())
lin = lambda : list(map(int, stdin.readline().split()))
n = iin()
a = lin()
a.sort()
ch = 0
incr = [a[0]]
dcr = []
for i in range(1, n):
	if a[i] == a[i - 1]:
		ch += 1
	else:
		ch = 0
	if ch == 1:
		dcr.append(a[i])
	elif ch == 0:
		incr.append(a[i])
	else:
		print('No')
		exit()
print('Yes')
print(len(incr))
print(*incr)
print(len(dcr))
dcr = dcr[::-1]
print(*dcr)


int(input())
a = list(map(int, input().split()))
g = 0
a.sort()
c = 0
l1 = []
l2 = []
for i in range(len(a) - 2):
	if a[i] == a[i + 1] and a[i] == a[i + 2]:
		c = 1
	if c == 1:
		break
if c == 1:
	print('NO')
else:
	for i in a:
		if g == 0:
			l1.append(i)
			g = 1
		else:
			l2.append(i)
			g = 0
	l2.sort(reverse=True)
	print('Yes')
	print(len(l1))
	for i in l1:
		print(i, end=' ')
	print('')
	print(len(l2))
	for i in l2:
		print(i, end=' ')


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])


n = int(input())
s = [int(i) for i in input().split()]
s.sort()
t = []
u = []
f = 0
for i in s:
	if len(t) == 0:
		t.append(i)
	elif t[len(t) - 1] != i:
		t.append(i)
	elif len(u) == 0:
		u.append(i)
	elif u[len(u) - 1] != i:
		u.append(i)
	else:
		f = 1
		break
if f == 1:
	print('NO')
else:
	print('YES')
	print(len(t))
	if len(t) != 0:
		for i in t:
			print(i, end=' ')
	print()
	print(len(u))
	if len(u) != 0:
		for i in range(len(u) - 1, -1, -1):
			print(u[i], end=' ')
	print()


n = int(input())
a = list(map(int, input().split()))
inf = 10 ** 6
inc = [inf for i in range(0, n + 1)]
dec = [-inf for i in range(0, n + 1)]
trinc = [-1 for i in range(0, n + 1)]
trdec = [-1 for i in range(0, n + 1)]
inc[0] = -inf
dec[0] = inf
for i in range(0, n - 1):
	if a[i + 1] < a[i]:
		if inc[i + 1] > inc[i]:
			inc[i + 1] = inc[i]
			trinc[i + 1] = 1
	if a[i + 1] > a[i]:
		if dec[i + 1] < dec[i]:
			dec[i + 1] = dec[i]
			trdec[i + 1] = 1
	if a[i + 1] > inc[i]:
		if dec[i + 1] < a[i]:
			dec[i + 1] = a[i]
			trdec[i + 1] = 0
	if a[i + 1] < dec[i]:
		if inc[i + 1] > a[i]:
			inc[i + 1] = a[i]
			trinc[i + 1] = 0
if inc[n - 1] == inf and dec[n - 1] == -inf:
	print('NO')
	exit(0)
now_inc = False
ans = [0 for i in range(0, n)]
if inc[n - 1] != inf:
	now_inc = True
for i in range(n - 1, -1, -1):
	if now_inc:
		ans[i] = 1
		if trinc[i] == 0:
			now_inc = False
	else:
		ans[i] = 0
		if trdec[i] == 0:
			now_inc = True
print('YES')
print(' '.join((str(x) for x in ans)))


N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
S = set(A)
r1 = []
r1.append(A.pop())
r2 = []
cnt = 1
C = []
while A:
	tmp = A.pop()
	if tmp != r1[-1]:
		r1.append(tmp)
	elif len(r2) == 0:
		r2.append(tmp)
	elif tmp != r2[-1]:
		r2.append(tmp)
	else:
		C.append(tmp)
r2 = r2[::-1]
if C:
	print('NO')
else:
	print('YES')
	print(len(r1))
	print(' '.join(map(str, r1)))
	print(len(r2))
	print(' '.join(map(str, r2)))


import sys
n = int(input())
z = list(map(int, input().split()))
z.sort()
a = set()
b = set()
for x in z:
	if x not in a:
		a.add(x)
	elif x not in b:
		b.add(x)
	else:
		print('NO')
		sys.exit()
print('YES')
print(len(a))
print(*sorted(a))
print(len(b))
print(*sorted(b, reverse=True))


n = int(input())
a = sorted(list(map(int, input().split())))
(inc, dec) = ([], [])
cnt = 1
maxcnt = 1
for i in range(n - 1):
	if a[i] == a[i + 1]:
		cnt += 1
		maxcnt = max(cnt, maxcnt)
	else:
		cnt = 1
if maxcnt > 2:
	print('NO')
else:
	for j in range(n - 1):
		if a[j] == a[j + 1]:
			dec.append(a[j])
		else:
			inc.append(a[j])
	inc.append(a[n - 1])
	print('YES', len(inc), *inc, len(dec), *dec[::-1], sep='\n')


def comma_to_space(arr):
	b = ''
	for i in arr:
		b += str(i) + ' '
	return b
n = int(input())
array = list(map(int, input().split()))
array = sorted(array)
a = -3274543
b = -1213421
increase = []
decrease = []
var = 1
for i in array:
	if b == i:
		if a == i:
			var = 0
			print('NO')
			break
		else:
			decrease.append(i)
	else:
		increase.append(i)
	a = b
	b = i
if var == 1:
	print('yes' + '\n' + str(len(increase)) + '\n' + comma_to_space(increase) + '\n' + str(len(decrease)) + '\n' + comma_to_space(decrease[::-1]))


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
increase = []
decrease = []
decrease.append(arr.pop())
for i in range(len(arr) - 1, -1, -1):
	if arr[i] < decrease[-1]:
		decrease.append(arr.pop(i))
if len(arr) > 0:
	increase.insert(0, arr.pop(0))
	for i in range(len(arr)):
		if arr[0] > increase[-1]:
			increase.append(arr.pop(0))
if len(arr) > 0:
	print('No')
else:
	result = ['Yes', str(len(increase)), ' '.join((str(i) for i in increase)), str(len(decrease)), ' '.join((str(i) for i in decrease))]
	print('\n'.join(result))


n = int(input())
arr = [int(i) for i in input().split()]
arr = sorted(arr)
countMap = {}
flag = 1
for i in arr:
	if i in countMap:
		countMap[i] += 1
		if countMap[i] >= 3:
			flag = 0
			break
	else:
		countMap[i] = 1
if flag == 1:
	(inc, dec) = ([], [])
	for num in countMap:
		inc.append(num)
		countMap[num] -= 1
		if countMap[num] == 1:
			dec.append(num)
			countMap[num] -= 1
	print('YES')
	print(len(inc))
	print(*inc)
	print(len(dec))
	print(*sorted(dec, reverse=True))
else:
	print('NO')


from sys import stdin, stdout
n = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
l = [0 for i in range(2 * 10 ** 5 + 1)]
ans = True
maxx = 0
(cb, cf) = (0, 0)
for i in range(n):
	l[a[i]] += 1
	k = l[a[i]]
	maxx = max(maxx, a[i])
	if k == 1:
		cb += 1
	elif k == 2:
		cf += 1
	if k > 2:
		ans = False
		break
if ans:
	stdout.write('YES' + '\n')
	stdout.write(str(cb) + '\n')
	for i in range(maxx + 1):
		if l[i] > 0:
			stdout.write(str(i) + ' ')
	stdout.write('\n' + str(cf) + '\n')
	for i in range(maxx, -1, -1):
		if l[i] == 2:
			stdout.write(str(i) + ' ')
	print(' ')
else:
	stdout.write('NO' + '\n')


from collections import Counter
n = int(input())
l = list(map(int, input().split()))
c = Counter(l)
d = c.values()
for i in d:
	if i > 2:
		print('NO')
		break
else:
	l.sort()
	p1 = l[::2]
	p2 = l[1::2]
	print('YES')
	print(len(p1))
	print(*p1)
	print(len(p2))
	p2.reverse()
	print(*p2)


from collections import Counter
n = int(input())
arr = [int(x) for x in input().split()]
d = Counter(arr)
k = all((ele <= 2 for (i, ele) in d.items()))
if k:
	print('YES')
	if n == len(set(arr)):
		print(0)
		print()
		print(n)
		arr = sorted(arr, reverse=True)
		print(' '.join([str(x) for x in arr]))
	else:
		inc = []
		dec = []
		for (i, j) in d.items():
			if j == 2:
				inc.append(i)
				dec.append(i)
			else:
				dec.append(i)
		print(len(inc))
		inc = sorted(inc)
		print(' '.join([str(x) for x in inc]))
		print(len(dec))
		dec = sorted(dec, reverse=True)
		print(' '.join([str(x) for x in dec]))
else:
	print('NO')


input()
a = sorted(map(int, input().split()))
b = a[::2]
c = a[1::2]
if len(set(b)) + len(set(c)) < len(a):
	print('NO')
else:
	print('YES', len(b), *b, len(c), *c[::-1])


n = int(input())
a = list(map(int, input().split()))
a.sort()
uniq = {}
inc = []
dec = []
flag = True
for i in a:
	if uniq.get(i, 0) >= 2:
		print('NO')
		flag = False
		break
	elif uniq.get(i, 0) == 1:
		dec.append(i)
		uniq[i] = 2
	else:
		inc.append(i)
		uniq[i] = 1
if flag:
	print('YES')
	print(len(inc))
	for i in range(len(inc) - 1):
		print(inc[i], end=' ')
	print(inc[-1])
	print(len(dec))
	if len(dec):
		for i in range(len(dec) - 1, 0, -1):
			print(dec[i], end=' ')
		print(dec[0])
	else:
		print()


n = int(input())
a = list(map(int, input().split()))
a.sort()
one = []
two = []
for i in range(n):
	if i % 2 == 0:
		one.append(a[i])
	else:
		two.append(a[i])
if len(one) == len(list(set(one))) and len(two) == len(list(set(two))):
	print('YES')
	print(len(one))
	print(' '.join(map(str, one)))
	print(len(two))
	two.reverse()
	print(' '.join(map(str, two)))
else:
	print('NO')


N = int(input())
arr = input()
arr = [int(x) for x in arr.split(' ')]
ans1 = []
ans2 = []
arr.sort(reverse=True)
flag = 0
for i in range(len(arr)):
	if not ans1:
		ans1.append(arr[i])
	elif not ans2:
		ans2.append(arr[i])
	elif arr[i] < ans1[-1]:
		ans1.append(arr[i])
	elif arr[i] < ans2[-1]:
		ans2.append(arr[i])
	else:
		flag = 1
		break
if flag == 1:
	print('NO')
else:
	print('YES')
	print(len(ans1))
	if len(ans1) == 0:
		print('')
	else:
		for i in range(len(ans1) - 1, -1, -1):
			if i != 0:
				print(ans1[i], end=' ')
			else:
				print(ans1[i])
	print(len(ans2))
	if len(ans2) == 0:
		print('')
	else:
		for i in range(len(ans2)):
			print(ans2[i], end=' ')


n = int(input())
l = list(map(int, input().split()))
vis = [True] * len(l)
l.sort()
tmp = None
(a, b) = ([], [])
for i in range(len(l)):
	if tmp == None:
		tmp = l[i]
	elif tmp == l[i]:
		continue
	tmp = l[i]
	vis[i] = False
	a.append(l[i])
tmp = None
for i in range(len(l) - 1, -1, -1):
	if vis[i]:
		if tmp == None:
			tmp = l[i]
		elif tmp == l[i]:
			continue
		vis[i] = False
		b.append(l[i])
		tmp = l[i]
if sum(vis) != 0:
	print('NO')
	exit(0)
print('YES')
print(len(a))
print(' '.join([str(s) for s in a]))
print(len(b))
print(' '.join([str(s) for s in b]))


n = int(input())
l = list(map(int, input().split()))
d = {}
a = []
b = []
c = True
for i in l:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
for i in d:
	if d[i] > 2:
		c = False
	elif d[i] > 1:
		a.append(i)
		b.append(i)
	else:
		b.append(i)
a.sort()
b.sort(reverse=True)
if c == False:
	print('NO')
else:
	print('YES')
	print(len(a))
	if len(a) >= 1:
		for i in a:
			print(i, end=' ')
		print()
	else:
		print()
	print(len(b))
	for i in b:
		print(i, end=' ')


n = int(input())
arr = [int(x) for x in input().split()]
arr.sort()
increasing = []
decreasing = []
for i in range(n):
	e = arr[i]
	if len(increasing) == 0 or increasing[-1] < e:
		increasing.append(e)
		arr[i] = -1
for i in range(n - 1, -1, -1):
	e = arr[i]
	if arr[i] == -1:
		continue
	if len(decreasing) == 0 or decreasing[-1] > e:
		decreasing.append(e)
if len(increasing) + len(decreasing) == n:
	print('YES')
	print(len(increasing))
	for e in increasing:
		print(e, end=' ')
	print()
	print(len(decreasing))
	for e in decreasing:
		print(e, end=' ')
	print()
else:
	print('NO')


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
x = []
y = []
d = dict(Counter(a))
if max(d.values()) > 2:
	print('NO')
else:
	s = list(set(a))
	for i in s:
		if d[i] == 2:
			x.append(i)
			y.append(i)
		else:
			x.append(i)
	print('YES')
	print(len(x))
	x.sort()
	print(*x)
	print(len(y))
	y.sort(reverse=True)
	print(*y)


n = int(input())
array = input()
A = [int(x) for x in array.split()]
is_possible = 'YES'
inc = []
dec = []
inc_counter = 0
dec_counter = 0
A.sort()
for x in A:
	if inc == [] or inc[-1] != x:
		inc.append(x)
		inc_counter += 1
	elif dec == [] or dec[-1] != x:
		dec.append(x)
		dec_counter += 1
	else:
		is_possible = 'NO'
		break
dec = dec[::-1]
print(is_possible)
if is_possible == 'YES':
	print(inc_counter)
	print(' '.join([str(number) for number in inc]))
	print(dec_counter)
	print(' '.join([str(number) for number in dec]))


from collections import Counter
input()
a = [int(x) for x in input().split()]
c = Counter(a)
if c.most_common(1)[0][1] > 2:
	print('NO')
else:
	print('YES')
	a = []
	b = []
	for e in c.items():
		a.append(e[0])
		if e[1] == 2:
			b.append(e[0])
	a.sort()
	print(len(a))
	print(*a)
	b.sort(reverse=True)
	print(len(b))
	print(*b)


n = int(input())
s = list(map(lambda x: int(x), input().split()))
c = {}
for q in s:
	if q in c:
		c[q] += 1
	else:
		c[q] = 1
v = []
u = []
flag = True
for q in c:
	if c[q] > 2:
		flag = False
		break
if flag:
	lss = list(set(s))
	for q in lss:
		if c[q] == 2:
			v.append(q)
	for q in lss:
		if c[q] > 0:
			u.append(q)
	print('Yes')
	print(len(v))
	print(*sorted(v))
	print(len(u))
	print(*sorted(u, reverse=True))
else:
	print('No')


import sys
n = int(input())
s = list(map(int, input().split()))
d = dict()
ok = True
for i in range(n):
	if s[i] in d:
		d[s[i]] += 1
	else:
		d[s[i]] = 1
	if d[s[i]] > 2:
		print('NO')
		sys.exit()
ans1 = []
ans2 = []
for i in d:
	ans1.append(i)
	d[i] -= 1
for i in d:
	if d[i] != 0:
		ans2.append(i)
ans1.sort()
ans2.sort(reverse=True)
print('YES')
print(len(ans1))
print(*ans1)
print(len(ans2))
print(*ans2)


from collections import Counter
n = int(input())
l = list(map(int, input().split()))
l.sort()
dec = []
asc = []
for i in range(n - 1):
	if l[i] == l[i + 1]:
		dec.append(l[i])
asc = list((Counter(l) - Counter(dec)).elements())
asc.sort()
dec.sort(reverse=True)
y = 0
x = 0
for i in range(len(asc) - 1):
	if asc[i] == asc[i + 1]:
		x = 1
for i in range(len(dec) - 1):
	if dec[i] == dec[i + 1]:
		y = 1
z = 0
if x == 1 or y == 1:
	print('NO')
else:
	z = 1
if z == 1:
	print('YES')
	print(len(asc))
	print(*asc)
	print(len(dec))
	print(*dec)


n = int(input())
inp = input()
inp = inp.split(' ')
numbers = []
for number in inp:
	number = int(number)
	numbers.append(number)
count = {}
result = 'YES'
for number in numbers:
	if number not in count:
		count[number] = 1
	elif count[number] > 1:
		result = 'NO'
		break
	else:
		count[number] += 1
if result == 'NO':
	print('NO')
else:
	print('YES')
	(descending, ascending) = ([], [])
	for number in count:
		if count[number] > 1:
			descending.append(number)
			ascending.append(number)
		else:
			ascending.append(number)
	ascending.sort()
	descending.sort(reverse=True)
	print(len(ascending))
	for item in ascending:
		print(item, end=' ')
	print()
	print(len(descending))
	for item in descending:
		print(item, end=' ')
	print()


_ = int(input())
k = list(map(int, input().split()))
if len(k) == 1:
	print('YES')
	print(1)
	print(k[0])
	print(0)
	print()
	exit()
up_set_from_k = set(k)
temp = set(k)
C = []
for i in k:
	if i in temp:
		temp.discard(i)
	else:
		C.append(i)
down_set_from_k = set(C)
if len(C) != len(down_set_from_k):
	print('NO')
	exit()
upk = list(up_set_from_k)
upk.sort()
downk = list(down_set_from_k)
downk.sort(reverse=True)
print('YES')
print(len(upk))
print(' '.join(map(str, upk)))
print(len(downk))
print(' '.join(map(str, downk)))


n = int(input())
numbers = list(map(int, input().split()))
if n == 1:
	one = [numbers[0]]
	two = []
else:
	numbers.sort()
	one = [numbers[0]]
	two = [numbers[1]]
	for i in numbers[2:]:
		if i != one[-1]:
			one.append(i)
			continue
		if i != two[-1]:
			two.append(i)
			continue
		print('NO')
		exit()
print('YES')
print(len(one))
for i in one:
	print(i, end=' ')
print()
print(len(two))
for i in reversed(two):
	print(i, end=' ')
print()


n = int(input())
lst = list(map(int, input().split()))
asc = []
desc = []
lst.sort()
f = False
check = True
inc = {}
for i in range(n):
	inc[lst[i]] = 0
for i in range(n):
	inc[lst[i]] += 1
	if inc[lst[i]] > 2:
		print('NO')
		check = False
		break
	elif inc[lst[i]] == 2:
		if not f:
			desc.append(lst[i])
			f = True
		else:
			asc.append(lst[i])
			f = False
	elif f:
		desc.append(lst[i])
	else:
		asc.append(lst[i])
if check:
	print('YES')
	print(len(asc))
	for i in range(len(asc)):
		print(asc[i], end=' ')
	print()
	print(len(desc))
	desc.reverse()
	for i in range(len(desc)):
		print(desc[i], end=' ')
	print()


def _f(n, arr):
	arr.sort()
	arr_1 = []
	arr_2 = []
	arr_1.append(arr[0])
	if len(arr) > 1:
		arr_2.append(arr[1])
	for i in range(2, len(arr)):
		if arr[i] == arr_1[-1] and arr[i] == arr_2[-1]:
			return (False, [], [])
		elif arr[i] == arr_1[-1]:
			arr_2.append(arr[i])
		else:
			arr_1.append(arr[i])
	arr_2.sort(reverse=True)
	return (True, arr_1, arr_2)

def f(n, arr):
	(result, arr_1, arr_2) = _f(n, arr)
	if result:
		print('YES')
		print(len(arr_1))
		print(''.join((str(e) + ' ' for e in arr_1)))
		print(len(arr_2))
		print(''.join((str(e) + ' ' for e in arr_2)))
	else:
		print('NO')
n = int(input())
arr = list(map(int, input().split()))
f(n, arr)


from collections import defaultdict
amount = int(input())
numbers = list(map(int, input().split()))
increasing = []
decreasing = []
memo = defaultdict(int)
for i in range(amount):
	current = numbers[i]
	memo[current] += 1
	count = 1
	if memo[current] > 2:
		print('No')
		break
else:
	increasing = sorted((el for el in memo if memo[el] == 2))
	decreasing = sorted(memo, reverse=True)
	print('Yes')
	print(len(increasing))
	print(' '.join(map(str, increasing)))
	print(len(decreasing))
	print(' '.join(map(str, decreasing)))


import sys
input = sys.stdin.readline
n = int(input())
b = list(map(int, input().split()))
c = dict()
d = []
e = []
f = 0
for j in range(n):
	if b[j] in c.keys():
		c[b[j]] += 1
	else:
		c[b[j]] = 1
a = sorted(list(set(b)))
for j in range(len(a)):
	if c[a[j]] == 1:
		d.append(a[j])
	elif c[a[j]] == 2:
		d.append(a[j])
		e.append(a[j])
	else:
		f = 1
		break
if f == 1:
	print('NO')
else:
	print('YES')
	print(len(d))
	print(*d)
	print(len(e))
	e.reverse()
	print(*e)


n = int(input())
a = list(map(int, input().split()))
a.sort()
s1 = []
s2 = []
if len(a) % 2 == 0:
	for i in range(0, len(a), 2):
		s1.append(a[i])
	for i in range(len(a) - 1, 0, -2):
		s2.append(a[i])
else:
	for i in range(0, len(a), 2):
		s1.append(a[i])
	for i in range(len(a) - 2, 0, -2):
		s2.append(a[i])
if len(set(s1)) < len(s1) or len(set(s2)) < len(s2):
	print('NO')
else:
	print('YES')
	print(len(s1))
	if len(s1) == 0:
		print()
	else:
		for i in range(len(s1)):
			print(s1[i], end=' ')
	print(len(s2))
	if len(s2) == 0:
		print()
	else:
		for i in range(len(s2)):
			print(s2[i], end=' ')


n = int(input())
e = set()
o = set()
for v in map(int, input().split()):
	if v not in e:
		e.add(v)
	elif v not in o:
		o.add(v)
	else:
		print('NO')
		break
else:
	print('YES')
	print(len(e))
	print(*sorted(e))
	print(len(o))
	print(*sorted(o, reverse=True))


n = int(input())
l = list(map(int, input().split()))
l.sort()
d = {}
a = []
b = []
for x in l:
	if x not in d:
		d[x] = 1
		a.append(x)
	else:
		b.append(x)
		d[x] += 1
		if d[x] >= 3:
			print('NO')
			exit()
else:
	print('YES')
	print(len(b))
	print(*b)
	print(len(a))
	print(*a[::-1])


import sys
n = int(input())
a = list(map(int, input().split(' ')))
a.sort()
for i in range(2, len(a)):
	if a[i] == a[i - 1] and a[i] == a[i - 2]:
		print('NO')
		sys.exit()
rise = [a[0]]
descent = []
for i in range(1, len(a)):
	if a[i] == a[i - 1]:
		descent.append(a[i])
	else:
		rise.append(a[i])
print('YES')
print(len(rise))
print(*rise)
print(len(descent))
descent.sort(reverse=True)
print(*descent)


n = int(input())
l = list(map(int, input().split(' ')))
i = 0
c = 1
l = sorted(l)
more = False
while i < n - 1:
	if l[i] == l[i + 1]:
		c += 1
	else:
		c = 1
	if c >= 3:
		more = True
		break
	i += 1
if more:
	print('NO')
else:
	left = []
	right = []
	left.append(l[0])
	i = 1
	while i < n:
		if l[i] == l[i - 1]:
			right.append(l[i])
		else:
			left.append(l[i])
		i += 1
	print('YES')
	print(len(left))
	for x in left:
		print(x, end=' ')
	print()
	print(len(right))
	if len(right) == 0:
		print()
	for x in range(len(right) - 1, -1, -1):
		print(right[x], end=' ')


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])


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')


input()
x = set()
y = set()
for a in map(int, input().split()):
	if a not in x:
		x.add(a)
	elif a in y:
		print('NO')
		break
	else:
		y.add(a)
else:
	print('YES')
	print(len(x))
	print(*sorted(x))
	print(len(y))
	print(*sorted(y, reverse=True))


import sys
amount = int(input())
array = [int(s) for s in input().split()]
array = sorted(array)
counter = [0] * (2 * 10 ** 5 + 1)
for i in range(len(array)):
	counter[array[i]] += 1
if max(counter) > 2:
	print('NO')
	sys.exit(0)
inc = []
dec = []
for i in range(len(counter)):
	if counter[i] == 1:
		inc.append(i)
	elif counter[i] == 2:
		inc.append(i)
		dec.append(i)
print('YES')
print(len(inc))
print(' '.join((str(s) for s in inc)))
print(len(dec))
print(' '.join((str(s) for s in dec[::-1])))


n = int(input())
a = [int(j) for j in input().split()]
li = [0] * (2 * 10 ** 5 + 1)
var = 0
a.sort()
for x in a:
	li[x] += 1
for x in li:
	if x >= 3:
		var = 1
		break
if var == 1:
	print('NO')
else:
	print('YES')
	inc = []
	dec = []
	if n % 2 == 0:
		for x in range(0, n, 2):
			inc += [a[x]]
		for x in range(n - 1, 0, -2):
			dec += [a[x]]
	else:
		for x in range(0, n, 2):
			inc += [a[x]]
		for x in range(n - 2, 0, -2):
			dec += [a[x]]
	print(len(inc))
	print(*inc)
	print(len(dec))
	print(*dec)


n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr)
ans1 = []
ans2 = []
for i in range(len(arr) - 1, 0, -1):
	if arr[i] > arr[i - 1]:
		ans1.append(arr.pop(i))
if len(ans1) == 0:
	ans1.append(arr.pop(0))
elif arr[0] < ans1[-1]:
	ans1.append(arr.pop(0))
for i in range(len(arr) - 1, 0, -1):
	if arr[i] > arr[i - 1]:
		ans2.append(arr.pop(i))
if len(arr) != 0:
	if len(ans2) == 0:
		ans2.append(arr.pop(0))
	elif arr[0] < ans2[-1]:
		ans2.append(arr.pop(0))
ans1 = sorted(ans1)
if len(arr) != 0:
	print('NO')
else:
	print('YES')
	print(len(ans1))
	print(' '.join(map(str, ans1)))
	print(len(ans2))
	print(' '.join(map(str, ans2)))


import sys
n = int(sys.stdin.readline())
arr = list(map(int, sys.stdin.readline().split()))
m = 200005
dp = [0 for _ in range(m)]
for i in range(n):
	dp[arr[i]] += 1
(a, b) = ([], [])
for i in range(m):
	if dp[i] > 2:
		print('NO')
		sys.exit()
	elif dp[i] == 2:
		a.append(i)
		b.append(i)
	elif dp[i]:
		a.append(i)
print('YES')
print(len(a))
print(*a)
b.reverse()
print(len(b))
print(*b)


(z, s, t) = (input, set, len)
z()
l = sorted(map(int, z().split()))
(a, b) = (l[::2], l[1::2])
if t(s(a)) + t(s(b)) < t(l):
	print('NO')
else:
	print('YES', t(a), *a, t(b), *b[::-1])


TN = 1

def solution():
	n = int(input())
	a = sorted(list(map(int, input().split())))
	ans = 'YES'
	ni = 0
	inc = []
	nd = 0
	dec = []
	klv = {}
	keys = []
	for i in a:
		try:
			x = klv[i]
		except:
			klv[i] = 1
			keys.append(i)
		else:
			klv[i] += 1
	for i in keys:
		if klv[i] > 2:
			ans = 'NO'
			break
		elif klv[i] == 2:
			ni += 1
			nd += 1
			inc.append(i)
			dec.append(i)
		else:
			ni += 1
			inc.append(i)
	if ans == 'NO':
		print(ans)
	else:
		print(ans)
		print(ni)
		print(*inc)
		print(nd)
		print(*list(reversed(dec)))
while TN != 0:
	solution()
	TN -= 1


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)


import sys
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left
import math
from operator import itemgetter
from heapq import heapify, heappop, heappush
n = int(input())
l = list(map(int, input().split()))
x = dc(int)
f = 0
p = []
q = []
for i in l:
	x[i] += 1
	if x[i] > 2:
		f = 1
		break
	if x[i] == 1:
		q.append(i)
	elif x[i] == 2:
		p.append(i)
if f:
	print('NO')
else:
	print('YES')
	print(len(p))
	if not p:
		print()
	else:
		print(*sorted(p))
	print(len(q))
	print(*sorted(q, reverse=True))


import sys, math
from collections import defaultdict

def get_ints():
	return map(int, I().split())

def get_list():
	return list(map(int, I().split()))

def I():
	return sys.stdin.readline()
n = int(input())
s = sorted(get_list())
d = defaultdict(lambda : 0)
for i in s:
	d[i] += 1
flag = False
fl = False
P = []
Q = []
for (i, j) in d.items():
	if j > 2:
		flag = True
		break
	if j == 2:
		P.append(i)
		Q.append(i)
		fl = True
	else:
		Q.append(i)
if flag:
	print('NO')
else:
	print('YES')
	if fl:
		print(len(P))
		print(*sorted(P))
		print(len(Q))
		print(*sorted(Q, reverse=True))
	else:
		print(1)
		print(s[0])
		print(n - 1)
		print(*s[-1:0:-1])


n = int(input())
a = list(map(int, input().split()))
d = {}
inc = []
dec = []
for i in a:
	d[i] = d.get(i, 0) + 1
	if d[i] == 3:
		print('NO')
		break
	if d[i] == 1:
		dec.append(i)
	else:
		inc.append(i)
else:
	print('YES')
	print(len(inc))
	inc.sort()
	for i in inc:
		print(i, end=' ')
	print()
	print(len(dec))
	dec.sort()
	dec.reverse()
	for i in dec:
		print(i, end=' ')
	print()


N = int(input())
sk = [int(x) for x in input().split()]
inc = set({})
dec = set({})
for i in sk:
	if i in inc:
		if i in dec:
			print('NO')
			exit()
		dec.add(i)
	else:
		inc.add(i)
inc = sorted(list(inc))
dec = sorted(list(dec), reverse=True)
print('YES')
print(len(inc))
for i in inc:
	print(i, end=' ')
print()
print(len(dec))
for i in dec:
	print(i, end=' ')


n = int(input())
a = list(map(int, input().split()))
ans1 = []
ans2 = []
f = dict()
a.sort()
for x in a:
	if x in f:
		f[x] += 1
	else:
		f[x] = 1
for (key, value) in f.items():
	if value > 2:
		print('NO')
		exit(0)
	ans1.append(key)
	if value == 2:
		ans2.append(key)
print('YES')
ans2.reverse()
print(len(ans1))
print(' '.join((str(x) for x in ans1)))
print(len(ans2))
print(' '.join((str(x) for x in ans2)))


t = int(input())
l = list(map(int, input().split()))
x = []
y = []
flag = 0
jk = [0] * (max(l) + 1)
l.sort()
for i in l:
	jk[i] = jk[i] + 1
	if jk[i] == 3:
		flag = 1
		break
if t == 1:
	print('YES')
	print('0')
	print(' ')
	print('1')
	print(l[0])
else:
	for i in range(t):
		if i % 2 == 0:
			x.append(l[i])
		else:
			y.append(l[i])
	if flag == 1:
		print('NO')
	else:
		print('YES')
		print(len(x))
		for i in range(len(x)):
			print(x[i], end=' ')
		print('')
		print(len(y))
		y.reverse()
		for i in y:
			print(i, end=' ')


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')
			exit(0)
		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()


n = int(input())
arr = list(map(int, input().split()))
d_ = dict()
for i in arr:
	d_[i] = 0
for i in arr:
	d_[i] += 1
if len([i for i in d_.keys() if d_[i] > 2]) > 0:
	print('NO')
else:
	print('YES')
	arr.sort()
	x1 = arr[::2]
	x2 = arr[1::2][::-1]
	x1 = [str(x) for x in x1]
	x2 = [str(x) for x in x2]
	print(len(x1))
	print(' '.join(x1))
	print(len(x2))
	print(' '.join(x2))


import os
import heapq
import sys, threading
import math
import bisect
import operator
from collections import defaultdict
sys.setrecursionlimit(10 ** 5)
from io import BytesIO, IOBase

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def power(x, p, m):
	res = 1
	while p:
		if p & 1:
			res = res * x % m
		x = x * x % m
		p >>= 1
	return res

def inar():
	return [int(k) for k in input().split()]

def lcm(num1, num2):
	return num1 * num2 // gcd(num1, num2)

def main():
	t = 1
	for _ in range(t):
		n = int(input())
		arr = inar()
		l1 = []
		l2 = []
		dic = defaultdict(int)
		ok = 0
		for i in range(n):
			dic[arr[i]] += 1
			if dic[arr[i]] == 1:
				l1.append(arr[i])
			elif dic[arr[i]] == 2:
				l2.append(arr[i])
			elif dic[arr[i]] > 2:
				ok = 1
				break
		if ok:
			print('NO')
		else:
			print('YES')
			print(len(l1))
			l1.sort()
			print(*l1)
			print(len(l2))
			l2.sort(reverse=True)
			print(*l2)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def main():
	n = int(input())
	a = list(map(int, input().split()))
	count_arr = [0] * 200005
	res = 1
	for x in a:
		count_arr[x] += 1
		if count_arr[x] > 2:
			res = 0
			break
	inc_count = 0
	dec_count = 0
	if res == 0:
		print('NO')
	else:
		incr = []
		decr = []
		for i in range(200005):
			if count_arr[i] >= 1:
				incr.append(i)
				count_arr[i] -= 1
				inc_count += 1
			if count_arr[i] == 1:
				decr.append(i)
				dec_count += 1
		print('YES')
		print(inc_count)
		for x in incr:
			print(x, end=' ')
		print()
		print(dec_count)
		for x in decr[::-1]:
			print(x, end=' ')
		print()
main()


n = int(input())
l = list(map(int, input().split()))
dic = {}
for e in l:
	if e in dic:
		dic[e] += 1
	else:
		dic[e] = 1
if max(dic.values()) >= 3:
	print('NO')
else:
	l1 = []
	l2 = []
	l.sort()
	for i in range(n):
		if dic[l[i]] == 1:
			l1.append(l[i])
		else:
			l2.insert(0, l[i])
			dic[l[i]] -= 1
	print('YES')
	print(len(l1))
	print(' '.join(list(map(str, l1))))
	print(len(l2))
	print(' '.join(list(map(str, l2))))


n = int(input())
Seq = sorted(list(map(int, input().split())))
Stat = [''] * (2 * 10 ** 5 + 3)
A = []
B = []
for el in Seq:
	if 'A' in Stat[el] and 'B' in Stat[el]:
		print('NO')
		break
	elif 'A' in Stat[el]:
		B.append(el)
		Stat[el] += 'B'
	else:
		A.append(el)
		Stat[el] += 'A'
else:
	print('YES')
	print(len(A))
	print(*sorted(A))
	print(len(B))
	print(*reversed(sorted(B)))


n = int(input())
arr = list(map(int, input().split(' ')))
arr = sorted(arr)
asc = []
des = []
c = 0
asc.append(arr[0])
for i in range(1, len(arr)):
	if arr[i] == arr[i - 1] and arr[i] == arr[i - 2]:
		print('No')
		c = 1
		break
	elif arr[i] == arr[i - 1]:
		des.append(arr[i])
	else:
		asc.append(arr[i])
if c == 0:
	print('Yes')
	print(len(asc))
	print(*asc)
	print(len(des))
	print(*des[::-1])


n = int(input())
a = [int(s) for s in input().split()]
cnt = {}
for x in a:
	cnt[x] = cnt.get(x, 0) + 1
first = []
second = []
fail = False
for (k, v) in cnt.items():
	if v > 2:
		fail = True
		break
	first.append(k)
	if v == 2:
		second.append(k)
if fail:
	print('NO')
else:
	print('YES')
	first = sorted(first)
	second = list(reversed(sorted(second)))
	print(len(first))
	print(' '.join([str(t) for t in first]))
	print(len(second))
	print(' '.join([str(t) for t in second]))


n = int(input())
a = list(map(int, input().rstrip().split()))
p = dict()
for i in a:
	if i in p:
		p[i] += 1
	else:
		p[i] = 1
for i in p:
	if p[i] > 2:
		print('NO')
		exit()
inc = []
dec = []
for i in p:
	if p[i] == 2:
		inc.append(i)
		dec.append(i)
	else:
		dec.append(i)
inc.sort()
dec.sort(reverse=True)
print('YES')
print(len(inc))
print(*inc)
print(len(dec))
print(*dec)


n = int(input())
res = list(map(int, input().split()))
(d, no, res1, res2) = ({}, 0, [], [])
for i in res:
	if i in d:
		d[i] += 1
		if d[i] >= 3:
			no = 1
			print('NO')
			break
	else:
		d[i] = 1
if not no:
	for i in d:
		if d[i] == 1:
			res1.append(i)
			continue
		elif d[i] == 2:
			res1.append(i)
			res2.append(i)
			continue
	print('YES')
	print(len(res1))
	for i in sorted(res1):
		print(i, end=' ')
	print()
	print(len(res2))
	for i in sorted(res2, reverse=True):
		print(i, end=' ')


n = int(input())
l = [int(x) for x in input().split()]
l.sort()
l1 = []
l2 = []
dic = {}
for i in range(len(l)):
	if l[i] in dic:
		dic[l[i]] += 1
		if dic[l[i]] > 2:
			print('NO')
			exit(0)
		if dic[l[i]] == 2:
			l1.append(l[i])
			l2.append(l[i])
	else:
		dic[l[i]] = 1
da_vez = True
for i in dic:
	if dic[i] == 1:
		if da_vez:
			l1.append(i)
			da_vez = False
		else:
			l2.append(i)
			da_vez = True
l1.sort()
l2.sort(reverse=True)
print('YES')
print(len(l1))
print(*l1)
print(len(l2))
print(*l2)


n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
s = len(set(a))
d = {}
for i in a:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
b = []
w = []
if max(d.values()) > 2:
	print('NO')
else:
	for i in a:
		if d[i] == 2:
			b.append(i)
			d[i] -= 1
		else:
			w.append(i)
	print('YES')
	print(n - s)
	print(*sorted(b))
	print(s)
	print(*w)


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
flag = [0] * n
flag[0] = 1
valid = True
ct = 1
for i in range(1, len(arr)):
	if arr[i] != arr[i - 1]:
		flag[i] = 1
		ct += 1
for i in range(1, len(arr)):
	if flag[i] == 0 and flag[i] == flag[i - 1]:
		valid = False
		break
if valid:
	print('YES')
	print(ct)
	for i in range(len(arr)):
		if flag[i] == 1:
			print(arr[i], end=' ')
	print()
	print(n - ct)
	for i in range(len(arr) - 1, -1, -1):
		if flag[i] != 1:
			print(arr[i], end=' ')
	print()
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
counts = [0] * 200001
poss = True
mx = 0
for ai in a:
	counts[ai] += 1
	mx = max(mx, ai)
	if counts[ai] > 2:
		poss = False
		break
if not poss:
	print('NO')
else:
	seq1 = []
	for i in range(mx + 1):
		if counts[i] > 0:
			counts[i] -= 1
			seq1.append(i)
	seq2 = []
	for i in range(mx, -1, -1):
		if counts[i] > 0:
			seq2.append(i)
	print('YES')
	print(len(seq1))
	print(*seq1)
	print(len(seq2))
	print(*seq2)


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')
		exit()
print('YES')
print(len(inc))
print(*sorted(inc))
print(len(dec))
print(*sorted(dec, reverse=True))


n = int(input())
a = [int(x) for x in input().strip().split()]
ub = []
vs = []
error = 0
a.sort()
vs.append(a[0])
for i in a[1:]:
	if not i == vs[-1]:
		vs.append(i)
	elif not ub:
		ub.append(i)
	elif not i == ub[-1]:
		ub.append(i)
	else:
		print('NO')
		error = 1
		break
if error == 0:
	print('YES')
	print(len(vs))
	for i in vs:
		print(i, end=' ')
	print()
	print(len(ub))
	for i in range(len(ub)):
		print(ub[len(ub) - 1 - i], end=' ')


n = int(input())
a = list(map(int, input().split(' ')))
inc = list()
dec = list()
cnt = {}
flag = True
for x in a:
	try:
		cnt[x] += 1
		if cnt[x] > 2:
			flag = False
		elif cnt[x] == 2:
			dec.append(x)
	except:
		cnt[x] = 1
		inc.append(x)
if flag == False:
	print('NO')
	exit()
inc.sort()
dec.sort(reverse=True)
print('YES')
print(len(inc))
print(*inc)
print(len(dec))
print(*dec)


import sys
strInp = lambda : input().strip().split()
intInp = lambda : list(map(int, strInp()))
n = int(input())
arr = intInp()
ass = set([])
des = set([])
notP = False
for i in arr:
	if i not in ass:
		ass.add(i)
	elif i not in des:
		des.add(i)
	else:
		notP = True
		break
if notP:
	print('No')
else:
	ass = list(ass)
	des = list(des)
	ass.sort()
	des.sort(reverse=True)
	print('Yes')
	print(len(ass))
	for i in ass:
		print(i, end=' ')
	print(len(des))
	for i in des:
		print(i, end=' ')


n = int(input())
l = list(map(int, input().split()))
a = [0 for i in range(10 ** 6)]
f = 0
l = sorted(l)
a1 = []
a2 = []
for i in l:
	if a[i] == 1:
		a2.append(i)
		a[i] += 1
	elif a[i] == 2:
		f = 1
		break
	else:
		a1.append(i)
		a[i] += 1
if f == 1:
	print('NO')
else:
	print('YES')
	print(len(a1))
	for i in a1:
		print(i, end=' ')
	print()
	print(len(a2))
	for i in a2[::-1]:
		print(i, end=' ')
	print()


N = int(input())
A = list(map(int, input().split()))
d = {}
res = True
inc = []
dec = []
for i in A:
	r = d.get(i, 0) + 1
	d[i] = r
	if r == 1:
		inc.append(i)
	elif r == 2:
		dec.append(i)
	else:
		res = False
		break
if not res:
	print('NO')
else:
	sinc = sorted(inc)
	ninc = len(inc)
	sdec = sorted(dec, reverse=True)
	ndec = len(dec)
	print('YES')
	print(ninc)
	sinc = list(map(str, sinc))
	print(' '.join(sinc))
	print(ndec)
	sdec = list(map(str, sdec))
	print(' '.join(sdec))


import sys
inf = float('inf')
mod = 1000000007

def get_array():
	return list(map(int, sys.stdin.readline().split()))

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

def input():
	return sys.stdin.readline()

def main():
	n = int(input())
	arr = get_array()
	arr.sort()
	from collections import Counter
	x = Counter(arr)
	a = []
	b = []
	for i in x:
		if x[i] == 1:
			a.append(i)
			continue
		elif x[i] == 2:
			a.append(i)
			b.append(i)
		elif x[i] > 2:
			print('NO')
			return
	print('YES')
	print(len(a))
	a.sort()
	print(*a)
	print(len(b))
	b.sort(reverse=True)
	print(*b)
main()


n = int(input())
A = list(map(int, input().split()))
d = {}
for a in A:
	if a in d:
		d[a] += 1
	else:
		d[a] = 1
l = []
r = []
for (k, v) in d.items():
	if v == 1:
		l.append(k)
	elif v == 2:
		l.append(k)
		r.append(k)
	else:
		print('No')
		exit()
l.sort()
r.sort(reverse=True)
print('YES')
print(len(l))
print(*l)
print(len(r))
print(*r)


n = int(input())
s = [int(i) for i in input().split()]
(x, y) = (set(), set())
for i in range(n):
	if s[i] not in x:
		x.add(s[i])
	else:
		y.add(s[i])
a = len(x)
b = len(y)
x = sorted(list(x))
y = list(y)
y.sort(reverse=True)
if a + b == n:
	print('YES')
	print(a)
	print(*x)
	print(b)
	print(*y)
	print
else:
	print('NO')


n = int(input())
a = sorted(list(map(int, input().split())))
if len(a) == 1:
	print('YES\n0\n\n1')
	print(a[0])
else:
	(s1, s2) = ([a[0]], [a[1]])
	for q in range(2, len(a)):
		if s1[-1] != a[q]:
			s1.append(a[q])
		elif s2[-1] != a[q]:
			s2.append(a[q])
		else:
			print('NO')
			break
	else:
		print('YES')
		(s1, s2) = (sorted(s1), sorted(s2, reverse=True))
		print(len(s1))
		print(*s1)
		print(len(s2))
		print(*s2)


n = int(input())
z = tuple(map(int, input().split()))
a = set()
b = set()
for x in z:
	if x not in a:
		a.add(x)
	elif x not in b:
		b.add(x)
	else:
		print('NO')
		exit()
print('YES')
print(len(b))
print(*sorted(b))
print(len(a))
print(*sorted(a, reverse=True))


n = int(input())
a = list(map(int, input().split()))
a.sort()
inc = []
dec = []
flag = 'yes'
for i in a:
	if len(inc) == 0:
		inc.append(i)
	elif inc[-1] == i:
		if len(dec) == 0:
			dec.append(i)
		elif dec[-1] == i:
			print('No')
			flag = 'no'
			break
		else:
			dec.append(i)
	else:
		inc.append(i)
dec.sort(reverse=True)
if flag == 'yes':
	print('Yes')
	print(len(inc))
	print(*inc)
	print(len(dec))
	print(*dec)


n = int(input())
l = [int(e) for e in input().strip().split()]
l.sort()
inc = []
dec = []
for i in range(len(l) - 1):
	if l[i] != l[i + 1]:
		inc.append(l[i])
inc.append(l[-1])
for i in range(len(l) - 2, -1, -1):
	if l[i] == l[i + 1]:
		dec.append(l[i])
for i in range(len(l) - 2):
	if l[i] == l[i + 1] == l[i + 2]:
		print('NO')
		break
else:
	print('YES')
	print(len(inc))
	for i in inc:
		print(i, end=' ')
	print()
	print(len(dec))
	for i in dec:
		print(i, end=' ')


n = int(input())
a = [int(x) for x in input().split()]
a.sort()
back = []
forw = []
flag = 0
for i in range(n - 1):
	if i < n - 2 and a[i] == a[i + 1] and (a[i] == a[i + 2]):
		print('NO')
		quit()
	elif a[i] == a[i + 1]:
		back.append(a[i])
		forw.append(a[i])
		flag = 1
	else:
		if flag == 0:
			forw.append(a[i])
		flag = 0
if flag == 0:
	forw.append(a[n - 1])
print('YES')
print(len(forw))
for ele in forw:
	print(ele, end=' ')
print()
print(len(back))
for i in range(len(back) - 1, -1, -1):
	print(back[i], end=' ')


from collections import defaultdict
d = defaultdict(lambda : 0)
n = int(input())
l = input().strip().split(' ')
l = list(map(int, l))
length = len(l)
flag = 0
for i in range(length):
	d[l[i]] += 1
	if d[l[i]] == 3:
		print('NO')
		flag = 1
		break
if flag == 0:
	l1 = []
	l2 = []
	for item in d.items():
		if item[1] == 2:
			l1.append(item[0])
			l2.append(item[0])
		else:
			l1.append(item[0])
	l1.sort(reverse=True)
	l2.sort()
	print('YES')
	print(len(l2))
	for i in l2:
		print(i, end=' ')
	print()
	print(len(l1))
	for i in l1:
		print(i, end=' ')
	print()


from sys import stdin, stdout
import sys
import math
sys.setrecursionlimit(15000)

def get_freq(arr):
	freq = [0] * 200001
	for i in arr:
		freq[i] += 1
	return freq

def check(freq):
	for i in freq:
		if i > 2:
			return False
	return True
n = stdin.readline().strip()
arr = list(map(int, stdin.readline().split()))
arr.sort()
freq = get_freq(arr)
if check(freq):
	first = []
	second = []
	for i in range(len(freq)):
		if freq[i] == 1:
			first.append(i)
		elif freq[i] == 2:
			first.append(i)
			second.append(i)
	first.sort(reverse=True)
	print('YES')
	print(len(second))
	print(*second)
	print(len(first))
	print(*first)
else:
	print('NO')


N = int(input())
nums = [int(i) for i in input().split(' ')]
nums.sort()
a1 = []
a2 = []
f = False
for i in range(N):
	if i % 2 == 0:
		if len(a1) > 0 and a1[-1] == nums[i]:
			f = True
			break
		a1.append(nums[i])
	else:
		if len(a2) > 0 and a2[-1] == nums[i]:
			f = True
			break
		a2.append(nums[i])
if f:
	print('No')
else:
	print('Yes')
	print(len(a1))
	print(' '.join([str(i) for i in a1]))
	print(len(a2))
	print(' '.join([str(i) for i in a2[::-1]]))


from collections import Counter
n = int(input())
b = sorted(list(map(int, input().split())))
c = Counter(b)
for i in b:
	if c[i] > 2:
		print('NO')
		exit()
print('YES')
print(len(b[::2]))
print(*b[::2])
if len(b) % 2 != 0:
	print(len(b[len(b) - 2:0:-2]))
	print(*b[len(b) - 2:0:-2])
else:
	print(len(b[:0:-2]))
	print(*b[:0:-2])


n = int(input())
l = list(map(int, input().split()))
l1 = []
l2 = []
from collections import defaultdict
d = defaultdict(int)
ans = 'YES'
for i in l:
	d[i] += 1
	if d[i] == 1:
		l1.append(i)
	elif d[i] == 2:
		l2.append(i)
	else:
		ans = 'NO'
		break
l1.sort()
l2.sort(reverse=True)
print(ans)
if ans == 'YES':
	print(len(l1))
	print(*l1)
	print(len(l2))
	print(*l2)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
from math import sqrt, floor, factorial, gcd
from collections import deque, Counter, defaultdict
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from collections import deque
input = lambda : sys.stdin.readline().rstrip('\r\n')
read = lambda : list(map(int, input().strip().split(' ')))

def solve():
	n = int(input())
	arr = read()
	s1 = set()
	s2 = set()
	for i in arr:
		if not i in s1:
			s1.add(i)
		elif not i in s2:
			s2.add(i)
		else:
			print('NO')
			return
	print('YES')
	print(len(s1))
	print(*sorted(s1))
	print(len(s2))
	print(*sorted(s2, reverse=True))
solve()


n = int(input())
a = list(map(int, input().split()))
occ = [0 for j in range(200001)]
inc = 0
dcr = 0
for i in a:
	if occ[i] == 2:
		print('No')
		break
	occ[i] += 1
	if occ[i] == 2:
		inc += 1
	else:
		dcr += 1
else:
	print('Yes')
	print(inc)
	for i in range(200001):
		if occ[i] == 2:
			print(i, end=' ')
			occ[i] -= 1
	print('\n' + str(dcr))
	for i in range(200000, -1, -1):
		if occ[i] == 1:
			print(i, end=' ')


n = int(input())
l = list(map(int, input().split()))
dp = [0] * len(l)
l.sort()
e = [l[0]]
dp[0] = 1
c = l[0]
for i in range(1, len(l)):
	if l[i] > c:
		e.append(l[i])
		c = l[i]
		dp[i] = 1
tag = True
for i in range(len(dp) - 1, -1, -1):
	if dp[i] == 0:
		tag = False
		break
if tag:
	print('Yes')
	print(len(e))
	print(*e)
	print(0)
	print()
else:
	c = l[i]
	y = [c]
	tag = True
	for t in range(i - 1, -1, -1):
		if dp[t] == 0:
			if l[t] < c:
				y.append(l[t])
				c = l[t]
			else:
				tag = False
				break
	if tag:
		print('Yes')
		print(len(e))
		print(*e)
		print(len(y))
		print(*y)
	else:
		print('No')


n = int(input())
a = list(map(int, input().split()))
a.sort()
p1 = []
p2 = []
for i in range(n):
	if i % 2 == 0:
		p1.append(a[i])
	else:
		p2.append(a[i])
if len(set(p1)) == len(p1) and len(set(p2)) == len(p2):
	print('YES')
	print(len(p1))
	print(*p1)
	print(len(p2))
	print(*p2[::-1])
else:
	print('NO')


(n, p) = (int(input()), 0)
a = list(map(int, input().split()))
a.sort()
(b, c) = ([], [])
from collections import Counter
d = Counter()
for i in a:
	d[i] += 1
	if d[i] >= 3:
		p = p + 1
		break
(k, l) = (0, 0)
if p == 1:
	print('NO')
else:
	d = sorted(zip(d.keys(), d.values()))
	for i in d:
		if i[1] == 1:
			b.append(i[0])
			l = l + 1
		else:
			b.append(i[0])
			c.append(i[0])
			l = l + 1
			k = k + 1
	c.reverse()
	print('YES')
	print(l)
	print(*b)
	print(k)
	print(*c)


from collections import Counter
n = int(input())
a = sorted(list(map(int, input().split())))
for s in list(Counter(a).values()):
	if s > 2:
		print('NO')
		exit()
inc = []
dec = []
t = 0
for char in a:
	if t == 0:
		inc.append(char)
	else:
		dec.append(char)
	t = (t + 1) % 2
inc = [str(i) for i in inc]
dec = [str(i) for i in dec]
print('YES')
print(len(inc))
print(' '.join(inc))
print(len(dec))
print(' '.join(dec[::-1]))


n = int(input())
a = [int(i) for i in input().split()]
d = dict()
for i in a:
	if d.get(i):
		d[i] += 1
		if d[i] >= 3:
			print('NO')
			exit(0)
	else:
		d[i] = 1
up = []
down = []
for i in d.keys():
	up.append(i)
	d[i] -= 1
for i in d.keys():
	if d[i] != 0:
		down.append(i)
		d[i] -= 1
up.sort()
down.sort(reverse=True)
print('YES')
print(len(up))
print(*up)
print(len(down))
print(*down)


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(sys.stdin.readline())
x = list(map(int, sys.stdin.readline().split(' ')))
a = set()
b = set()
for element in x:
	if element not in a:
		a.add(element)
	elif element not in b:
		b.add(element)
	else:
		print('NO')
		exit()
a = list(map(str, sorted(list(a))))
b = list(map(str, sorted(list(b), key=lambda x: -x)))
print('YES')
print(len(a))
print(' '.join(a))
print(len(b))
if len(b) > 0:
	print(' '.join(b))
else:
	print()


a = int(input())
z = list(map(int, input().split()))
from collections import defaultdict
al = defaultdict(int)
z.sort()
inc = []
for i in range(len(z)):
	al[z[i]] += 1
z = list(set(z))
for i in range(len(z)):
	if al[z[i]] > 2:
		print('NO')
		exit()
inc = []
dec = []
for i in range(len(z)):
	if al[z[i]] == 1:
		inc.append(z[i])
	else:
		inc.append(z[i])
		dec.append(z[i])
print('YES')
inc.sort()
print(len(inc))
print(*inc)
dec.sort(reverse=True)
print(len(dec))
print(*dec)


def main():
	n = int(input())
	a = sorted(list(map(int, input().split())))

	def check3():
		for i in range(len(a) - 2):
			if a[i] == a[i + 1] and a[i + 1] == a[i + 2]:
				return False
		return True
	if not check3():
		print('NO')
	else:
		inc = []
		dec = []
		pos = 0
		while pos < len(a):
			if pos == len(a) - 1:
				inc.append(a[pos])
				pos += 1
			elif a[pos] == a[pos + 1]:
				inc.append(a[pos])
				dec.append(a[pos + 1])
				pos += 2
			else:
				inc.append(a[pos])
				pos += 1
		inc.sort()
		dec.sort(reverse=True)
		print('YES')
		print(len(inc))
		print(' '.join(map(str, inc)))
		print(len(dec))
		print(' '.join(map(str, dec)))
main()


n = int(input())
a = list(map(int, input().split()))
a.sort()
i = 0
m = 0
c = 1
while i < n - 1:
	if a[i] == a[i + 1]:
		c = c + 1
	else:
		if c > m:
			m = c
		c = 1
	i = i + 1
ic = []
dc = []
if m <= 2:
	ic = list(set(a))
	i = 0
	while i < n - 1:
		if a[i] == a[i + 1]:
			dc.append(a[i])
		i = i + 1
	dc.reverse()
	print('YES')
	print(len(ic))
	for i in ic:
		print(i, end=' ')
	print()
	print(len(dc))
	for i in dc:
		print(i, end=' ')
else:
	print('NO')


def getSets(sequenceElements):
	incr_set = []
	decr_set = []
	for el in sequenceElements:
		(content, freq) = el
		if freq > 2:
			return ('NO', [], [])
		if freq > 0:
			incr_set += [content]
			el[1] -= 1
	for i in range(0, len(sequenceElements)):
		index = len(sequenceElements) - i - 1
		(content, freq) = sequenceElements[index]
		if freq > 0:
			decr_set += [content]
	return ('YES', incr_set, decr_set)

def printSeq(seq):
	string = ''
	for i in range(0, len(seq)):
		string += str(seq[i])
		if i != len(seq) - 1:
			string += ' '
	print(string)
sequenceLenght = int(input())
sequence = []
for c in input().split(' '):
	sequence += [int(c)]
sequence.sort()
sequenceElements = []
elementPosition = {}
for i in range(0, sequenceLenght):
	c = sequence[i]
	if c in elementPosition:
		pos = elementPosition[c]
		sequenceElements[pos][1] += 1
	else:
		elementPosition[c] = len(sequenceElements)
		sequenceElements += [[c, 1]]
sets = getSets(sequenceElements)
if sets[0] == 'NO':
	print('NO')
else:
	print('YES')
	len1 = len(sets[1])
	print(len1)
	if len1 == 0:
		print()
	else:
		printSeq(sets[1])
	len2 = len(sets[2])
	print(len2)
	if len2 == 0:
		print()
	else:
		printSeq(sets[2])


n = int(input())
a = sorted(list(map(int, input().split())))
voz = [-1]
ub = [-1]
b = True
for i in range(n - 1):
	if a[i] == a[i + 1]:
		if ub[0] == a[i]:
			print('NO')
			b = False
			break
		ub.insert(0, a[i])
	else:
		if voz[-1] == a[i]:
			print('NO')
			b = False
			break
		voz.append(a[i])
if b:
	if voz[-1] == a[n - 1]:
		print('NO')
		b = False
	else:
		voz.append(a[n - 1])
	print('YES')
	print(len(voz) - 1)
	print(' '.join(map(str, voz[1:])))
	print(len(ub) - 1)
	if len(ub) > 1:
		print(' '.join(map(str, ub[:-1])))
	else:
		print()


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)
threading.stack_size(2 ** 27)
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):
	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
	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):
	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 = []
entry_finder = {}
REMOVED = '<removed-task>'

def add_task(task, priority=0):
	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):
	entry = entry_finder.pop(task)
	entry[-1] = REMOVED

def pop_task():
	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):
	fn = lambda x: li[x] - x // i
	x = -1
	b = len(li)
	while b >= 1:
		while b + x < len(li) and fn(b + x) > 0:
			x += b
		b = b // 2
	return x
TestCases = False
testingMode = False
fac_warmup_size = 10 ** 5 + 100
optimiseForReccursion = True
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)
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())
l = list(map(int, input().split()))
freq = dict()
for i in range(n):
	if l[i] not in freq:
		freq[l[i]] = 1
	else:
		freq[l[i]] += 1
flag = 0
inc = []
for (key, value) in freq.items():
	if value >= 3:
		flag = 1
		break
	if value > 1:
		inc.append(key)
		freq[key] -= 1
if flag == 1:
	print('No')
else:
	print('Yes')
	print(len(inc))
	print(*sorted(list(set(inc))))
	print(len(set(l)))
	print(*sorted(list(set(l)), reverse=True))


n = int(input())
arr = list(map(int, input().split()))
arr2 = []
arr3 = []
x = 1
flag = 0
arr.sort()
for i in range(1, len(arr)):
	if arr[i] == arr[i - 1]:
		arr2.append(arr[i - 1])
		x += 1
	else:
		arr3.append(arr[i - 1])
		x = 1
	if x == 3:
		flag = 1
		break
arr3.append(arr[-1])
if flag:
	print('NO')
else:
	print('YES')
	print(len(arr3))
	for i in arr3:
		print(i, end=' ')
	print()
	print(len(arr2))
	for i in arr2[::-1]:
		print(i, end=' ')
	print()


n = int(input())
arr = list(map(int, input().split()))
dic = {}
for i in range(n):
	if arr[i] not in dic:
		dic[arr[i]] = 1
	else:
		dic[arr[i]] += 1
inc = []
dec = []
flag = 0
for i in dic.keys():
	if dic[i] > 2:
		flag = 1
		break
	if dic[i] == 2:
		inc.append(i)
	dec.append(i)
if flag == 1:
	print('NO')
else:
	print('YES')
	if len(inc) > 0:
		inc.sort()
		print(len(inc))
		print(*inc)
	else:
		print(0)
		print('')
	if len(dec) > 0:
		dec.sort(reverse=True)
		print(len(dec))
		print(*dec)
	else:
		print(0)
		print(dec)


n = int(input())
combined = [int(x) for x in input().split()]
(inc, dec) = (set(), set())
while combined:
	current = combined.pop()
	if current not in inc:
		inc.add(current)
	elif current not in dec:
		dec.add(current)
if len(inc) + len(dec) == n:
	inc = [str(i) for i in sorted(list(inc))]
	dec = [str(i) for i in sorted(list(dec), reverse=True)]
	print('YES')
	print(len(inc))
	print(*inc)
	print(len(dec))
	print(*dec)
else:
	print('NO')


from collections import Counter
n = int(input())
a = sorted(list(map(int, input().split())))
c = Counter(a)
inc = set(a)
dec = []
for i in inc:
	if c[i] == 2:
		dec.append(i)
if len(dec) + len(inc) == n:
	print('YES')
	print(len(inc))
	print(*sorted(list(inc)))
	print(len(dec))
	print(*sorted(dec, reverse=True))
else:
	print('NO')


acorrect = True
n = int(input())
inp = input()
a = list(map(int, inp.split()))
a.sort()

def ans():
	if n == 1:
		print('YES')
		print('1')
		print(a[0])
		print('0')
		return
	for i in range(len(a) - 2):
		if a[i] == a[i + 1] and a[i] == a[i + 2]:
			print('NO')
			return
	r = [a[0]]
	l = []
	for i in range(1, len(a) - 1):
		if r[-1] != a[i]:
			r.append(a[i])
		else:
			l.append(a[i])
	l.append(a[len(a) - 1])
	l.reverse()
	print('YES')
	print(len(r))
	print(' '.join(map(str, r)))
	print(len(l))
	print(' '.join(map(str, l)))
ans()


from collections import defaultdict as dd
n = int(input())
l = [int(x) for x in input().split()]
v = dd(int)
for i in range(n):
	v[l[i]] += 1
d = list(v.keys())
k = 0
for i in range(len(v)):
	if v[d[i]] > 2:
		print('NO')
		k = 1
		break
if k == 0:
	a = []
	b = []
	l.sort()
	for i in range(0, n, 2):
		a.append(l[i])
	for i in range(1, n, 2):
		b.append(l[i])
	print('YES')
	print(len(a))
	print(*a)
	b.reverse()
	print(len(b))
	print(*b)


import sys
from bisect import bisect_left, bisect_right
from collections import deque
inf = float('inf')
mod = 1000000007

def binary(number):
	result = 0
	while number:
		result = result + 1
		number = number & number - 1
	return result

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())
n = int(input())
array = get_array()
array.sort()

def main():
	cnt = 0
	increase = []
	decrease = []
	for x in array:
		if not increase:
			increase.append(x)
		elif increase[-1] == x:
			if not decrease:
				decrease.append(x)
			elif decrease[-1] == x:
				print('No')
				return
			else:
				decrease.append(x)
		else:
			increase.append(x)
	print('Yes')
	print(len(increase))
	print(' '.join(map(str, increase)))
	print(len(decrease))
	print(' '.join(map(str, reversed(decrease))))
main()


import sys
n = int(input())
A = list(map(int, input().split()))
A.sort()
s1 = [A[0]]
s2 = []
for i in range(1, n):
	if A[i] - s1[-1] > 0:
		s1.append(A[i])
	else:
		s2.append(A[i])
for i in range(len(s2) - 1):
	if s2[i] - s2[i + 1] == 0:
		print('NO')
		sys.exit()
print('YES')
print(len(s1))
for s in s1:
	print(s, end=' ')
print()
print(len(s2))
for i in range(len(s2) - 1, -1, -1):
	s = s2[i]
	print(s, end=' ')
print()


from collections import Counter as c
n = int(input())
l = sorted(list(map(int, input().split())))
x = c(l)
if max(x.values()) >= 3:
	print('NO')
	exit()
print('YES')
z = l[::2]
y = l[1::2]
print(len(z))
print(*z)
print(len(y))
print(*y[::-1])


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

def check(d):
	for (k, v) in d.items():
		if v > 2:
			return False
	return True
d = {}
for i in a:
	if i not in d:
		d[i] = 1
	else:
		d[i] += 1
if len(d) == 1:
	print('YES')
	print(0)
	print('')
	print(n)
	a.sort(reverse=True)
	print(' '.join([str(i) for i in a]))
elif not check(d):
	print('NO')
else:
	inc = []
	dec = []
	for (k, v) in d.items():
		if v == 2:
			inc.append(k)
			dec.append(k)
		else:
			dec.append(k)
	print('YES')
	print(len(inc))
	inc.sort()
	print(' '.join([str(i) for i in inc]))
	print(len(dec))
	dec.sort(reverse=True)
	print(' '.join([str(i) for i in dec]))


import sys
from bisect import bisect_left, bisect_right
from collections import deque, Counter
from math import gcd, sqrt, factorial, ceil, log
from itertools import permutations
inf = float('inf')
mod = 1000000007
mini = 1000000007

def fact(n):
	if n == 0:
		return 1
	p = 1
	d = 10 ** 9 + 7
	for i in range(1, n + 1):
		p = p * i
		p = p % d
	return p

def ncr(n, r):
	d = 10 ** 9 + 7
	num = fact(n)
	den = fact(r) * fact(n - r) % d
	den = pow(den, d - 2, d)
	return num * den % d

def sieve(n):
	prime = [True for i in range(n + 1)]
	lst = []
	p = 2
	while p * p <= n:
		if prime[p]:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p = p + 1
	for i in range(2, n + 1):
		if prime[i]:
			lst.append(i)
	return len(lst)

def binary(number):
	result = 0
	while number:
		result = result + 1
		number = number & number - 1
	return result

def calculate_factors(n):
	hh = [1] * (n + 1)
	p = 2
	while p * p < n:
		if hh[p] == 1:
			for i in range(p * 2, n, p):
				hh[i] = 0
		p += 1
	total = 1
	for p in range(2, n + 1):
		if hh[p] == 1:
			count = 0
			if n % p == 0:
				while n % p == 0:
					n = int(n / p)
					count += 1
				total *= count + 1
	return total

def prime_factors(n):
	i = 2
	factors = set()
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.add(i)
	if n > 1:
		factors.add(n)
	if len(factors) == 2:
		return True
	else:
		return False

def isPrime(n):
	if n == 2 or n == 3:
		return True
	if n % 2 == 0 or n < 2:
		return False
	for i in range(3, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return False
	return True

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
n = int(input())
Arr = get_array()
mydict = dict()
flag = 0
for i in Arr:
	mydict[i] = mydict.get(i, 0) + 1
for i in mydict:
	if mydict[i] > 2:
		flag = 1
		break
if flag == 1:
	print('NO')
else:
	inc = []
	dec = []
	Arr.sort()
	l = len(Arr)
	i = 0
	d = 0
	inc.append(Arr[0])
	for k in range(1, l):
		if Arr[k] > inc[i]:
			inc.append(Arr[k])
			i = i + 1
		else:
			dec.append(Arr[k])
			d = d + 1
	dec.sort(reverse=True)
	print('Yes')
	print(len(inc))
	print(*inc, sep=' ')
	print(len(dec))
	print(*dec, sep=' ')


import io, os
kk = lambda : map(int, input().split())
k2 = lambda : map(lambda x: int(x) - 1, input().split())
ll = lambda : list(kk())
(n, ls) = (int(input()), ll())
ls.sort()
lastv = -1
lastd = -1
(inc, dec) = ([], [])
for v in ls:
	if v == lastv:
		if lastd == v:
			print('NO')
			exit()
		dec.append(v)
		lastd = v
	else:
		lastv = v
		inc.append(v)
print('YES')
print(len(inc))
print(*inc)
dec.sort(reverse=True)
print(len(dec))
print(*dec)


n = int(input())
a = sorted(map(int, input().split()))
dec = a[::2]
inc = a[1::2]
if len(set(dec)) + len(set(inc)) < len(a):
	print('NO')
else:
	print('YES')
	print(len(inc))
	print(*inc)
	print(len(dec))
	print(*dec[::-1])


n = int(input())
l = list(map(int, input().split()))
l.sort()
a = [l[0]]
d = []
f = 0
for i in range(n):
	if i + 2 < n and l[i] == l[i + 1] == l[i + 2]:
		f = 1
		break
	if i != 0 and i + 1 < n and (l[i] == l[i + 1]):
		a.append(l[i])
	elif i != 0:
		d.append(l[i])
if f == 1:
	print('NO')
else:
	print('YES')
	print(len(a))
	print(*a)
	d.reverse()
	print(len(d))
	print(*d)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
import sys
input = sys.stdin.readline
scan_int = lambda : int(input())
scan_string = lambda : input().rstrip()
read_list = lambda : list(read())
read = lambda : map(int, input().split())
read_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def is_integer(n):
	return math.ceil(n) == math.floor(n)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(beauty, s, n, count):
	pass
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect

def solve():
	n = scan_int()
	a = read_list()
	a.sort()
	mp = {}
	for x in a:
		d = mp.get(x, 0)
		mp[x] = d + 1
		if mp[x] > 2:
			print('NO')
			return
	val = list(mp.keys())
	one = []
	two = []
	for x in val[:-1]:
		if mp[x] > 1:
			one.append(x)
			mp[x] -= 1
	if mp[val[-1]] > 0:
		one.append(val[-1])
		mp[val[-1]] -= 1
	for x in val[::-1]:
		if mp[x] > 0:
			two.append(x)
	print('YES')
	print(len(one))
	print(*one)
	print(len(two))
	print(*two)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for i in range(1):
	solve()


n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
inc = [-1]
dec = [-1]
li = ld = 0
for num in a:
	if num != inc[li]:
		inc.append(num)
		li += 1
	elif num != dec[ld]:
		dec.append(num)
		ld += 1
	else:
		print('NO')
		break
inc = inc[1:]
dec = dec[1:]
if li + ld == n:
	print('YES')
	print(li)
	print(' '.join(map(str, inc)))
	print(ld)
	print(' '.join(map(str, reversed(dec))))


import collections
n = int(input())
flag = 0
li = list(map(int, input().split()))
k = collections.Counter(li)
x = []
for i in k.keys():
	if k[i] > 2:
		flag = 1
		break
	elif k[i] == 2:
		x.append(i)
if flag == 1:
	print('NO')
else:
	z = list(dict.fromkeys(li))
	z = sorted(z)
	z = z[::-1]
	x = sorted(x)
	print('YES')
	print(len(x))
	for i in x:
		print(i, end=' ')
	print(end='\n')
	print(len(z))
	for j in z:
		print(j, end=' ')
	print(end='\n')


n = int(input())
li = list(map(int, input().strip().split()))
selected = [False] * n
li.sort()
inc = []
dec = []
for i in range(0, n):
	if i < n - 2 and li[i] == li[i + 1] and (li[i + 1] == li[i + 2]):
		print('No')
		break
	else:
		if li[i] == li[i - 1]:
			continue
		if selected[i] == False:
			inc.append(li[i])
			selected[i] = True
else:
	for i in range(n - 1, -1, -1):
		if selected[i] == False:
			dec.append(li[i])
	print('Yes')
	print(len(inc))
	for num in inc:
		print(num, end=' ')
	print()
	print(len(dec))
	for num in dec:
		print(num, end=' ')


def main():
	n = int(input())
	tab = list(map(int, input().split()))
	tab.sort()
	seen = {}
	dec = []
	croi = []
	for x in range(n):
		if tab[x] in seen:
			if seen[tab[x]] > 1:
				print('NO')
				return
			seen[tab[x]] += 1
			dec.append(tab[x])
		else:
			seen[tab[x]] = 1
			croi.append(tab[x])
	dec = dec[::-1]
	print('YES')
	print(len(croi))
	print(*croi)
	print(len(dec))
	print(*dec)
main()


n = int(input())
L = list(map(int, input().split()))
L.sort()
D = {}
for l in L:
	if l in D:
		D[l] += 1
	else:
		D[l] = 1
if max(D.values()) > 2:
	print('NO')
else:
	print('YES')
	A = set(L)
	print(len(A))
	print(' '.join(map(str, sorted(list(A)))))
	B = [x for (x, v) in D.items() if v == 2]
	print(len(B))
	print(' '.join(map(str, sorted(B, reverse=True))))


def suff(a, n):
	ainc = []
	adec = []
	if n == 0:
		print('YES')
		print('0')
		print('')
		print('0')
		print('')
		return
	elif n == 1:
		ainc.append(a[0])
		print('YES')
		print('1')
		print(*ainc)
		print('0')
		print('')
		return
	elif n == 2:
		print('YES')
		print('1')
		print(a[0])
		print('1')
		print(a[1])
	else:
		a.sort()
		ainc.append(a[0])
		adec.append(a[1])
		for i in range(1, n - 1):
			if ainc[-1] < a[i + 1]:
				ainc.append(a[i + 1])
			elif adec[-1] < a[i + 1]:
				adec.append(a[i + 1])
			else:
				print('NO')
				return
		print('YES')
		print(len(ainc))
		print(*ainc)
		print(len(adec))
		print(*adec[::-1])
		return
n = int(input())
a = list(map(int, input().split()))
x = suff(a, n)


from collections import Counter
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys
n = int(sys.stdin.readline())
arr = list(map(int, input().split()))
arr.sort()
a = []
b = []
for i in range(n):
	if arr[i] != arr[i - 1] or i == 0:
		a.append(arr[i])
	else:
		b.append(arr[i])
		if i >= 2 and arr[i] == arr[i - 2]:
			print('NO')
			exit()
print('YES')
print(len(a))
b.sort()
b = b[::-1]
print(*a)
print(len(b))
print(*b)


t = int(input())
l = [int(x) for x in input().split()]
d = dict()
for i in l:
	if d.get(i) == None:
		d[i] = 1
	else:
		d[i] = d[i] + 1
f = 0
l1 = []
l2 = []
for (k, v) in d.items():
	if v >= 3:
		f = 1
	if v == 2:
		l1.append(k)
		l2.append(k)
	else:
		l2.append(k)
if f == 1:
	print('NO')
else:
	print('YES')
	if len(l1) == 0:
		print(0)
	else:
		l1.sort()
		print(len(l1))
		for i in l1:
			print(i, end=' ')
		print()
	l2.sort(reverse=True)
	print(len(l2))
	for i in l2:
		print(i, end=' ')


input()
n = [int(x) for x in input().split()]
n = sorted(n)
inc = [n[0]]
dec = []
prev = n[0]
n[0] = -1
for i in range(1, len(n)):
	if prev == n[i]:
		continue
	inc += [n[i]]
	prev = n[i]
	n[i] = -1
prev = -1
for i in range(len(n) - 1, -1, -1):
	if n[i] == prev or n[i] == -1:
		continue
	dec += [n[i]]
	prev = n[i]
if len(dec) + len(inc) != len(n):
	print('NO')
else:
	print('YES')
	print(len(inc))
	for e in inc:
		print(e, end=' ')
	print()
	print(len(dec))
	for e in dec:
		print(e, end=' ')
	print()


import sys
import time
start = time.time()
n = int(input())
arr = list(map(int, input().split()))
inc = set()
dec = set()
flag = True
for a in arr:
	if a not in inc:
		inc.add(a)
	elif a not in dec:
		dec.add(a)
	else:
		print('No')
		flag = False
		break
if flag:
	print('Yes')
	print(len(inc))
	print(' '.join(list(map(str, sorted(list(inc))))))
	print(len(dec))
	print(' '.join(list(map(str, sorted(list(dec), reverse=True)))))
end = time.time()


from __future__ import division, print_function
import io
import os
import sys
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from cStringIO import StringIO
	from future_builtins import ascii, filter, hex, map, oct, zip
else:
	from io import BytesIO as StringIO
(sys.stdout, stream) = (io.IOBase(), StringIO())
sys.stdout.flush = lambda : os.write(1, stream.getvalue()) and (not stream.truncate(0)) and stream.seek(0)
sys.stdout.write = stream.write if sys.version_info[0] < 3 else lambda s: stream.write(s.encode())
(input, flush) = (sys.stdin.readline, sys.stdout.flush)
input = StringIO(os.read(0, os.fstat(0).st_size)).readline

def main():
	n = int(input())
	a = sorted(map(int, input().split()))
	increasing = [a[0]]
	decreasing = []
	p = a[0]
	for i in a[1:]:
		if i != p:
			increasing.append(i)
		else:
			decreasing.append(i)
		p = i
	if len(set(decreasing)) != len(decreasing):
		print('NO')
		return
	decreasing.reverse()
	print('YES')
	print(len(increasing))
	print(*increasing)
	print(len(decreasing))
	print(*decreasing)
main()


n = int(input())
a = list(map(int, input().split()))
mydict = {}
repeat = []
for i in a:
	if i not in mydict:
		mydict[i] = 1
	else:
		mydict[i] += 1
		if mydict[i] > 2:
			print('NO')
			exit()
		repeat.append(i)
print('YES')
x = []
for i in mydict:
	if mydict[i] == 1:
		x.append(i)
l = len(x)
y = set(x[l // 2:l])
x = set(x[:l // 2])
for i in repeat:
	x.add(i)
	y.add(i)
x = list(x)
x.sort()
print(len(x), ' '.join(map(str, x)), sep='\n')
print(len(y))
y = list(y)
y.sort()
for i in range(1, len(y) + 1):
	print(y[-i], end=' ')


n = int(input())
a = list(map(int, input().split()))
increasing = []
decreasing = []
dict = {}
a = sorted(a)
flag = 0
for i in a:
	if i not in dict:
		dict[i] = 1
		increasing.append(i)
	else:
		dict[i] += 1
		decreasing.append(i)
	if dict[i] == 3:
		flag = 1
		break
decreasing = decreasing[::-1]
if flag == 1:
	print('NO')
else:
	print('YES')
	print(len(increasing))
	for i in increasing:
		print(i, end=' ')
	print()
	print(len(decreasing))
	for j in decreasing:
		print(j, end=' ')
	print()


def mp():
	return map(int, input().split())
n = int(input())
a = list(mp())
a.sort()
l = []
r = []
fail = False
for i in a:
	if len(l) == 0 or l[-1] < i:
		l.append(i)
	elif len(r) == 0 or r[-1] < i:
		r.append(i)
	else:
		fail = True
		break
if fail:
	print('NO')
else:
	print('YES')
	print(len(l))
	for i in l:
		print(i, end=' ')
	print()
	print(len(r))
	for i in r[::-1]:
		print(i, end=' ')


N = int(input())
A = list(map(int, input().split()))
A.sort()
dec = []
inc = []
result = 'YES'
last = None
count = 0
for a in A:
	if a != last:
		inc.append(a)
		last = a
		count = 1
	elif count == 1:
		dec.insert(0, a)
		count += 1
	else:
		result = 'NO'
		break
print(result)
if result == 'YES':
	print(len(inc))
	print(' '.join([str(x) for x in inc]))
	print(len(dec))
	print(' '.join([str(x) for x in dec]))


n = input()
a = input().split()
a = [int(i) for i in a]
l = {}
canSplit = True
incre = []
for i in a:
	if i not in l:
		l[i] = 1
	else:
		l[i] += 1
	if l[i] > 2:
		canSplit = False
	elif l[i] == 2:
		incre.append(i)
if canSplit:
	print('YES')
	print(len(incre))
	incre.sort()
	incre = [str(i) for i in incre]
	print(' '.join(incre))
	decre = list(l.keys())
	decre.sort(reverse=True)
	decre = [str(i) for i in decre]
	print(len(decre))
	print(' '.join(decre))
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
a.sort()
x = []
y = []
s = 0
flag = True
for i in range(1, n):
	if a[i] == a[i - 1]:
		s += 1
	else:
		s = 0
	if s > 1:
		flag = False
		break
im = True
for i in a:
	if im:
		x.append(i)
		im = False
	else:
		y.append(i)
		im = True
x.sort()
y.sort()
y.reverse()
if flag:
	print('YES')
	print(len(x))
	for i in x:
		print(i, end=' ')
	print()
	print(len(y))
	for i in y:
		print(i, end=' ')
else:
	print('NO')


(n, a) = (int(input()), [int(i) for i in input().split()] + [0])
(ans, inc, dec) = ([0 for _ in range(n)], -1, float('inf'))
for i in range(n):
	if inc < a[i] < dec:
		if a[i] < a[i + 1]:
			inc = a[i]
		else:
			dec = a[i]
			ans[i] = 1
	elif inc < a[i]:
		inc = a[i]
	elif dec > a[i]:
		dec = a[i]
		ans[i] = 1
	else:
		print('NO')
		break
else:
	print('YES')
	print(*ans)


n = int(input())
a = [int(s) for s in input().split()]
a.sort()
(inc, dec) = ([a[0]], [])
valid = True
for i in range(1, n):
	if a[i] == inc[-1]:
		if dec and dec[-1] == a[i]:
			valid = False
			break
		dec.append(a[i])
	else:
		inc.append(a[i])
if valid:
	print('YES')
	print(len(inc))
	print(*inc)
	dec.sort(reverse=True)
	print(len(dec))
	print(*dec)
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
a.sort()
l = []
g = []
ex = 0
erw = 0
for i in range(len(a)):
	try:
		if a[i] == a[i + 1] == a[i + 2]:
			print('NO')
			ex = 1
			exit(1)
			break
	except:
		rt = 0
	if ex == 1:
		break
	try:
		if a[i] == a[i + 1]:
			g.append(a[i])
			erw = 1
			continue
	except:
		gh = 0
	l.append(a[i])
if ex == 0:
	print('YES')
	print(len(g))
	print(*g)
	print(len(l))
	print(*reversed(l))


n = int(input())
a = list(map(int, input().split()))
b = [0] * 200010
m = len(a)
for i in range(0, m):
	b[a[i]] += 1
t = 0
cnt = 0
for i in range(0, 200001):
	if b[i] > 2:
		t = 1
	if b[i] > 0:
		cnt += 1
if t == 1:
	print('NO')
else:
	print('YES')
	print(cnt)
	for i in range(0, 200001):
		if b[i] > 0:
			b[i] -= 1
			print(i, end=' ')
	print()
	print(n - cnt)
	for i in reversed(range(0, 200001)):
		if b[i] > 0:
			print(i, end=' ')


def fucn():
	n = int(input())
	lis = list(map(int, input().split()))
	dic = {}
	for i in lis:
		try:
			dic[i] = dic[i] + 1
			if dic[i] == 3:
				print('NO')
				return
		except KeyError:
			dic[i] = 1
	print('YES')
	l1 = []
	l2 = []
	for i in dic:
		if dic[i] == 1:
			l2.append(i)
		else:
			l2.append(i)
			l1.append(i)
	l1.sort()
	l2.sort(reverse=True)
	print(len(l1))
	if len(l1) != 0:
		for i in l1:
			print(i, end=' ')
	print()
	print(len(l2))
	if len(l2) != 0:
		for i in l2:
			print(i, end=' ')
fucn()


def main():
	n = int(input())
	a = sorted([int(x) for x in input().split()])
	(up, down) = (set(), set())
	for x in a:
		if x in up and x in down:
			print('NO')
			return
		elif x in down:
			up.add(x)
		else:
			down.add(x)
	print('YES')
	print(len(up))
	print(' '.join([str(x) for x in sorted(up)]))
	print(len(down))
	print(' '.join([str(x) for x in sorted(down, reverse=True)]))
main()


n = int(input())
nn = list(map(int, input().rstrip().split()))
dct = dict()
lst1 = []
lst2 = []
flag = 0
for i in nn:
	dct.setdefault(i, 0)
	dct[i] += 1
for key in sorted(dct):
	if dct[key] > 2:
		print('NO')
		flag = 1
		break
	elif dct[key] == 1:
		lst1.append(key)
	else:
		lst1.append(key)
		lst2.append(key)
if flag == 0:
	print('YES')
	lst1len = len(lst2)
	print(lst1len)
	print(*lst2, sep=' ')
	print(n - lst1len)
	lst1.sort(reverse=True)
	print(*lst1, sep=' ')


n = int(input())
a = [int(x) for x in input().split()]
asc = set()
dec = set()
answer = ''
for i in range(len(a)):
	if a[i] not in asc:
		asc.add(a[i])
	elif a[i] not in dec:
		dec.add(a[i])
	else:
		pass
if len(asc) + len(dec) == n:
	answer = 'YES'
	asc_list = list(asc)
	asc_list.sort()
	dec_list = list(dec)
	dec_list.sort(reverse=True)
	print(answer)
	print(len(asc_list))
	print(*asc_list)
	print(len(dec_list))
	print(*dec_list)
else:
	answer = 'NO'
	print(answer)


n = int(input())
a = list(map(int, input().split()))
a.sort()
b = []
b += (a[0],)
c = []
for x in a[1:]:
	if x != b[-1]:
		b += (x,)
	else:
		c += (x,)
if len(c) > len(set(c)):
	print('NO')
else:
	print('YES')
	print(len(b))
	print(*b)
	print(len(c))
	c.sort(reverse=True)
	print(*c)


n = int(input())
a = list(map(int, input().split())) + [0]
answer = [0] * n
current_increase_max = -1
current_decrease_min = 1000000.0
for i in range(n):
	if current_increase_max < a[i] and a[i] < current_decrease_min:
		if a[i] < a[i + 1]:
			current_increase_max = a[i]
			answer[i] = 0
		else:
			current_decrease_min = a[i]
			answer[i] = 1
	elif current_increase_max < a[i]:
		current_increase_max = a[i]
		answer[i] = 0
	elif current_decrease_min > a[i]:
		current_decrease_min = a[i]
		answer[i] = 1
	else:
		print('NO')
		exit(0)
print('YES')
print(*answer)


n = int(input())
counts = [0] * 200001
incorrect = False
for i in input().split():
	counts[int(i)] += 1
	if counts[int(i)] > 2:
		incorrect = True
		break
if incorrect:
	print('NO')
else:
	print('YES')
	up = []
	down = []
	for (i, c) in enumerate(counts):
		if c == 2:
			up.append(i)
		if c:
			down.append(i)
	print(len(up))
	for i in up:
		print(i, end=' ')
	print()
	print(len(down))
	for i in reversed(down):
		print(i, end=' ')


from collections import defaultdict as ddict
n = int(input())
a = map(int, input().split())
inc = list()
dec = list()
count = ddict(int)
for it in a:
	count[it] += 1
	if count[it] == 1:
		inc.append(it)
	elif count[it] == 2:
		dec.append(it)
	else:
		print('NO')
		exit()
print('YES')
print(len(inc))
for it in sorted(inc):
	print(it, end=' ')
print()
print(len(dec))
if len(dec) == 0:
	print('')
else:
	for it in sorted(dec, key=lambda w: -w):
		print(it, end=' ')


import sys
input()
numbers = list(map(int, sys.stdin.readline().split()))
ascending = []
descending = []
is_no = False
numbers.sort()
prev = -1
cont = 0
for number in numbers:
	if prev == number:
		cont += 1
	else:
		cont = 0
		prev = number
	if cont == 2:
		is_no = True
		print('No')
		break
	elif cont == 1:
		descending.append(number)
	else:
		ascending.append(str(number))
if not is_no:
	print('YES')
	print(len(ascending))
	print(' '.join(ascending))
	print(len(descending))
	descending.sort(reverse=True)
	for (i, num) in enumerate(descending):
		descending[i] = str(num)
	print(' '.join(descending))


from sys import exit
n = int(input())
nums = list(map(int, input().split()))
nums.sort()
vozr = [nums[0]]
ubiv = []
for num in nums[1:]:
	if vozr[-1] != num:
		vozr.append(num)
	elif not ubiv or ubiv[0] != num:
		ubiv.insert(0, num)
	else:
		print('NO')
		exit()
print('YES')
print(len(vozr))
print(*vozr)
print(len(ubiv))
print(*ubiv)


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
arr1 = []
arr2 = []
i = 0
flag = 0
while i < n:
	if i < n - 1 and arr[i] == arr[i + 1]:
		if i < n - 2 and arr[i] == arr[i + 2]:
			flag = 1
			break
		else:
			arr1.append(arr[i])
			arr2.append(arr[i])
			i += 1
	else:
		arr1.append(arr[i])
	i += 1
if flag == 1:
	print('No')
else:
	print('Yes')
	print(len(arr1))
	print(*arr1)
	print(len(arr2))
	arr2 = arr2[::-1]
	print(*arr2)


n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
(inc, dec) = ([], [])
inc.append(a[0])
flag = [False for i in range(n)]
flag[0] = True
c = 1
for i in range(len(a)):
	if flag[i] == False and a[i] > inc[-1]:
		inc.append(a[i])
		flag[i] = True
		c += 1
end = -1
for i in range(n - 1, -1, -1):
	if flag[i] == False:
		dec.append(a[i])
		flag[i] = True
		end = i - 1
		c += 1
		break
for i in range(end, -1, -1):
	if flag[i] == False and a[i] < dec[-1]:
		dec.append(a[i])
		flag[i] = True
		c += 1
if c < n:
	print('NO')
else:
	print('YES')
	print(len(inc))
	for i in range(len(inc)):
		print(inc[i], end=' ')
	print()
	print(len(dec))
	for i in range(len(dec)):
		print(dec[i], end=' ')
	print()


def run(n, a):
	dic = {}
	for i in a:
		dic[i] = dic.get(i, 0) + 1
	inc = []
	dec = []
	for i in dic.keys():
		if dic[i] >= 3:
			print('NO')
			return None
		else:
			inc.append(i)
			if dic[i] == 2:
				dec.append(i)
	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()))
run(n, a)


from collections import Counter
n = int(input())
l = list(map(int, input().split()))
d = dict(Counter(l))
val = list(d.values())
if max(val) > 2:
	print('NO')
else:
	print('YES')
	kk = []
	for h in d.keys():
		if d[h] == 2:
			kk.append(h)
	kk.sort()
	jj = list(d.keys())
	jj = list(set(jj))
	jj.sort(reverse=True)
	print(len(kk))
	print(' '.join((str(x) for x in kk)))
	print(len(jj))
	print(' '.join((str(x) for x in jj)))


def countFreq(arr, n):
	mp = dict()
	for i in range(n):
		if arr[i] in mp.keys():
			mp[arr[i]] += 1
		else:
			mp[arr[i]] = 1
	return mp
n = int(input())
l = sorted(list(map(int, input().split())))
y = list(sorted(set(l)))
c = 0
b = []
a = []
s = 0
k = list(countFreq(l, n).values())
if max(k) > 2:
	print('NO')
else:
	print('YES')
	for i in range(len(y)):
		if k[i] > 1:
			b.append(y[i])
	print(len(b))
	print(*b)
	print(len(y))
	y.reverse()
	print(*y)


import sys

def solve(a):
	d = {}
	for el in a:
		if el not in d.keys():
			d[el] = 1
		else:
			d[el] += 1
			if d[el] == 3:
				return 'NO'
	inc = set()
	dec = set()
	for i in range(len(a)):
		if a[i] not in inc:
			inc.add(a[i])
		else:
			dec.add(a[i])
	inc = list(inc)
	dec = list(dec)
	inc.sort()
	dec = sorted(dec, reverse=True)
	q = str(len(inc))
	w = ' '.join(list(map(str, inc)))
	e = str(len(dec))
	r = ' '.join(list(map(str, dec)))
	res = 'YES\n{}\n{}\n{}\n{}'.format(q, w, e, r)
	return res
n = int(sys.stdin.readline().strip())
a = list(map(int, sys.stdin.readline().strip().split()))
res = solve(a)
sys.stdout.write(res + '\n')


n = int(input())
s = list(map(int, input().split()))
s.sort()
up = [s[0]]
down = []
count = 0
for i in range(1, len(s)):
	if s[i] == s[i - 1]:
		count += 1
	else:
		count = 0
	if count == 2:
		print('NO')
		exit()
	if count == 0:
		up.append(s[i])
	if count == 1:
		down.append(s[i])
down.reverse()
print('YES')
print(len(up))
print(' '.join(list(map(str, up))))
print(len(down))
print(' '.join(list(map(str, down))))


n = int(input())
n1 = list(map(int, input().split()))
n1.sort()
first = []
second = []
count = 0
result = 'YES'
i = 0
newdict = {}
for i in n1:
	if i in newdict.keys():
		newdict[i] += 1
	else:
		newdict[i] = 1
i = 0
while i < len(n1):
	if i < len(n1) - 1 and n1[i] == n1[i + 1]:
		first.append(n1[i])
		second.append(n1[i + 1])
		if i > 0 and n1[i] != n1[i - 1]:
			count = 0
		count += 1
		i += 2
		if count == 2:
			result = 'NO'
			break
	else:
		first.append(n1[i])
		count = 0
		i += 1
second.reverse()
strfirst = ''
strsecond = ''
for i in range(len(first)):
	if i == 0:
		strfirst += str(first[i])
	else:
		strfirst += ' ' + str(first[i])
for i in range(len(second)):
	if i == 0:
		strsecond += str(second[i])
	else:
		strsecond += ' ' + str(second[i])
if max(newdict.values()) > 2:
	result = 'NO'
if result == 'YES':
	print(result)
	print(len(first))
	print(strfirst)
	print(len(second))
	print(strsecond)
else:
	print('NO')


import random

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def main():
	n = ii()
	a = li()
	a = sorted(a)
	freq = [0] * (2 * 100000 + 1)
	for i in range(n):
		freq[a[i]] += 1
	if max(freq) > 2:
		print('NO')
		exit()
	a1 = []
	a2 = []
	for i in range(n):
		if i % 2 == 0:
			a1.append(a[i])
		else:
			a2.append(a[i])
	print('YES')
	print(len(a1))
	for i in a1:
		print(i, end=' ')
	print()
	print(len(a2))
	a2 = sorted(a2, reverse=True)
	for i in a2:
		print(i, end=' ')
main()


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
a = set()
b = set()
for i in arr:
	if i not in a:
		a.add(i)
	elif i not in b:
		b.add(i)
	else:
		print('NO')
		exit()
print('YES')
print(len(a))
print(*sorted(a))
print(len(b))
print(*sorted(b, reverse=True))


from sys import stdin, stdout
from math import gcd, ceil, sqrt
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
n = ii1()
arr = sorted(iia())
(a, b) = ([], [])
for i in arr:
	if len(a) and i == a[-1]:
		if len(b) and i == b[-1]:
			print('NO')
			break
		else:
			b.append(i)
	else:
		a.append(i)
else:
	print('YES')
	print(len(a))
	print(*a)
	print(len(b))
	print(*sorted(b, reverse=True))


def solution(arr):
	memo1 = set()
	memo2 = set()
	inc = []
	dec = []
	arr.sort()
	for a in arr:
		if a not in memo1:
			inc.append(a)
			memo1.add(a)
		elif a not in memo2:
			dec.append(a)
			memo2.add(a)
		else:
			return False
	dec.reverse()
	return [inc, dec]
n = int(input())
arr = [int(i) for i in input().split()]
ans = solution(arr)
if not ans:
	print('NO')
else:
	print('YES')
	print(len(ans[0]))
	print(*ans[0])
	print(len(ans[1]))
	print(*ans[1])


for t in range(1):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	counter = dict()
	for i in arr:
		if i in counter:
			counter[i] += 1
		else:
			counter[i] = 1
	inc = []
	broken = 0
	for i in counter:
		if counter[i] > 2:
			print('NO')
			broken += 1
			break
		elif counter[i] == 0:
			continue
		else:
			counter[i] -= 1
			inc.append(i)
	if broken == 0:
		dec = []
		for i in counter:
			if counter[i] == 0:
				continue
			else:
				dec.append(i)
				counter[i] -= 1
		print('YES')
		print(len(inc))
		print(*inc)
		dec.sort(reverse=True)
		print(len(dec))
		print(*dec)


n = int(input())
a = sorted([int(x) for x in input().split()])
(up, down) = (set(), set())
flag = 1
for x in a:
	if x in up and x in down:
		print('NO')
		flag = 0
		break
	elif x in down:
		up.add(x)
	else:
		down.add(x)
if flag == 1:
	print('YES')
	print(len(up))
	print(' '.join([str(x) for x in sorted(up)]))
	print(len(down))
	print(' '.join([str(x) for x in sorted(down, reverse=True)]))


n = int(input())
a = list(map(int, input().split()))
seq1 = []
seq2 = []
a.sort()
al = len(a)
seq1.append(a[0])
a[0] = -1
l1 = 1
l2 = 0
for i in range(n):
	if a[i] > seq1[l1 - 1] and a[i] != -1:
		seq1.append(a[i])
		l1 += 1
		a[i] = -1
for i in range(n):
	if a[i] != -1:
		seq2.append(a[i])
		l2 += 1
seq2.sort()
seq2.reverse()
count = 0
for i in range(l2 - 1):
	if seq2[i] > seq2[i + 1]:
		count += 1
t = 0
if al == l1:
	t = 1
elif al == l2:
	t = 1
elif count == l2 - 1:
	if l1 + l2 == al:
		t = 1
if t:
	print('YES')
	print(l1)
	print(*seq1)
	print(l2)
	print(*seq2)
else:
	print('NO')


inc = []
dec = []

def fun(arr, l):
	n = 200 * 1000 + 1
	dict = [0] * n
	for i in range(0, l):
		dict[arr[i]] = dict[arr[i]] + 1
		if dict[arr[i]] > 2:
			print('NO')
			return
	print('YES')
	print(dict.count(2))
	for i in range(0, n):
		if dict[i] == 2:
			print(i, end=' ')
			dict[i] = dict[i] - 1
	print()
	print(dict.count(1))
	for i in range(0, n):
		if dict[n - i - 1] == 1:
			print(n - i - 1, end=' ')
	return
l = int(input())
arr = [int(x) for x in input().split()]
fun(arr, l)


n = int(input())
s = list(map(int, input().split()))
s.sort()
flag = 1
cnt = {}
for i in s:
	if i in cnt:
		cnt[i] += 1
	else:
		cnt[i] = 1
a = cnt.keys()
for i in a:
	if cnt[i] > 2:
		flag = 0
		break
if flag:
	print('YES')
	dec = []
	inc = []
	for i in a:
		if cnt[i] == 2:
			inc.append(i)
			dec.append(i)
		else:
			inc.append(i)
	dec.sort(reverse=True)
	inc.sort()
	print(len(inc))
	print(*inc)
	print(len(dec))
	print(*dec)
else:
	print('NO')


(n, l) = (int(input()), list(map(int, input().split())))
d = {}
for i in l:
	if i in d:
		d[i] += 1
		if d[i] > 2:
			print('No')
			exit()
	else:
		d[i] = 1
(l1, l2) = ([], [])
for k in d:
	l1.append(k)
	if d[k] == 2:
		l2.append(k)
l1.sort()
l2.sort(reverse=True)
print('Yes')
print(len(l1))
print(' '.join((str(i) for i in l1)))
print(len(l2))
print(' '.join((str(i) for i in l2)))


d = {}
n = int(input())
a = [int(i) for i in input().split()]
for i in a:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
b = []
c = []
flag = 0
for (key, value) in d.items():
	if value >= 3:
		flag = 1
		break
	elif value == 2:
		b.append(key)
		c.append(key)
		d[key] = 1
	else:
		c.append(key)
if flag:
	print('NO')
else:
	print('YES')
	b.sort()
	print(len(b))
	for i in b:
		print(i, end=' ')
	print()
	c.sort(reverse=True)
	print(len(c))
	for i in c:
		print(i, end=' ')
	print()


n = int(input())
a = [int(s) for s in input().split()]
a.sort()
b = []
c = [a[0]]
flag = True
for i in range(1, n):
	if a[i - 1] == a[i]:
		if i < n - 1 and a[i] == a[i + 1]:
			flag = False
			break
		else:
			b.append(a[i])
	else:
		c.append(a[i])
if flag:
	b.sort(reverse=True)
	print('YES')
	print(len(c))
	print(*c)
	print(len(b))
	print(*b)
else:
	print('NO')


MAX = 1 + 2 * 10 ** 5
MIN = -1
ASC = 0
DSC = 1
n = int(input())
a = list(map(int, input().split()))
asc = MIN
dsc = MAX
res = []
for i in range(n):
	if a[i] > asc and a[i] < dsc:
		if i + 1 == n:
			res.append(DSC)
		elif a[i] > a[i + 1]:
			res.append(DSC)
			dsc = a[i]
		else:
			res.append(ASC)
			asc = a[i]
	elif a[i] > asc:
		res.append(ASC)
		asc = a[i]
	elif a[i] < dsc:
		res.append(DSC)
		dsc = a[i]
	else:
		print('NO')
		exit()
print('YES')
print(*res)


n = int(input())
a = list(map(int, input().split()))
a.sort()
f = 0
b = []
c = []
for i in range(n - 2):
	if a[i] == a[i + 1] == a[i + 2]:
		f = 1
if f == 1:
	print('NO')
else:
	b.append(a[0])
	for i in range(1, n):
		if a[i] == a[i - 1]:
			c.append(a[i])
		else:
			b.append(a[i])
	c.reverse()
	print('YES')
	print(len(b))
	print(*b)
	print(len(c))
	print(*c)


from collections import *
n = int(input())
l = sorted(list(map(int, input().split())))
sl = sorted(list(set(l)))
c = Counter(l)
for i in c:
	if c[i] >= 3:
		print('NO')
		exit()
print('YES')
if sl == l:
	print(1)
	print(l[0])
	print(n - 1)
	print(*reversed(l[1:]))
else:
	print(len(sl))
	print(*sl)
	oth = []
	for i in c:
		if c[i] == 2:
			oth.append(i)
	print(len(oth))
	oth.sort(reverse=True)
	print(*oth)


n = int(input())
Ar = [int(x) for x in input().split()]
Increasing_Array = []
Decreasing_Array = []
if n == 1:
	print('YES')
	print(1)
	print(Ar[0])
	print(0)
	print('\n')
	exit()
Ar.sort()
Increasing_Array.append(Ar[0])
Ar.remove(Ar[0])
cnt = 0
for i in Ar:
	if i != Increasing_Array[-1]:
		Increasing_Array.append(i)
	else:
		try:
			if i != Decreasing_Array[-1]:
				Decreasing_Array.append(i)
			else:
				print('NO')
				cnt += 1
				break
		except:
			Decreasing_Array.append(i)
if cnt == 0:
	Decreasing_Array.reverse()
	print('YES')
	print(len(Increasing_Array))
	for i in Increasing_Array:
		print(i, end=' ')
	print()
	print(len(Decreasing_Array))
	for i in Decreasing_Array:
		print(i, end=' ')


def check(line):
	lst = sorted(line, key=lambda s: int(s))
	for i in range(2, len(lst)):
		if lst[i] == lst[i - 2]:
			return False
	return lst

def main():
	n_row = input()
	line = input()
	num = line.strip(' ').split(' ')
	num = check(num)
	if num:
		print('YES')
	else:
		print('NO')
		return
	(odd, even) = ([], [])
	for i in range(0, len(num)):
		if i == 0 or num[i] != num[i - 1]:
			odd.append(num[i])
		else:
			even.append(num[i])
	print(len(odd))
	for i in odd:
		print(i, end=' ')
	print('')
	print(len(even))
	for i in sorted(even, key=lambda s: int(s), reverse=True):
		print(i, end=' ')
main()


from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, sin, cos, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(1000000000)
INF = float('inf')
(YES, Yes, yes, NO, No, no) = ('YES', 'Yes', 'yes', 'NO', 'No', 'no')
(dy4, dx4) = ([0, 1, 0, -1], [1, 0, -1, 0])
(dy8, dx8) = ([0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1])

def inside(y, x, H, W):
	return 0 <= y < H and 0 <= x < W

def ceil(a, b):
	return (a + b - 1) // b

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	g = gcd(a, b)
	return a / g * b

def euclidean_distance(y1, x1, y2, x2):
	return sqrt((y1 - y2) ** 2 + (x1 - x2) ** 2)

def manhattan_distance(y1, x1, y2, x2):
	return abs(y1 - y2) + abs(x1 - x2)

def main():
	N = int(input())
	A = list(sorted(list(map(int, input().split()))))
	c = Counter(A)
	for v in c.values():
		if v > 2:
			print(NO)
			return
	(inc, dec) = ([A[0]], [])
	used = [False] * N
	used[0] = True
	for i in range(1, N):
		if A[i] > inc[-1]:
			used[i] = True
			inc.append(A[i])
	for i in range(N - 1, -1, -1):
		if used[i]:
			continue
		dec.append(A[i])
	print(YES)
	print(len(inc))
	print(*inc, sep=' ')
	print(len(dec))
	print(*dec, sep=' ')
main()


from sys import exit
n = int(input())
left = []
right = []
v = [int(x) for x in input().split(' ')]
v.sort()
left.append(v[0])
for i in range(1, n):
	if v[i] > left[-1]:
		left.append(v[i])
	elif len(right) == 0 or right[-1] < v[i]:
		right.append(v[i])
	else:
		print('NO')
		exit(0)
print('YES')
print(len(left))
for x in left:
	print(x, end=' ')
print()
print(len(right))
right.reverse()
for x in right:
	print(x, end=' ')


_ = input()
seq = sorted(map(int, input().split()))

class ShouldNotGetHereException(Exception):
	pass
n_increasing = 0
increasing = []
n_decreasing = 0
decreasing = []
counts = [[seq[0], 0]]
impossible = False
for el in seq:
	if counts[-1][0] == el:
		if counts[-1][1] == 2:
			impossible = True
			break
		counts[-1][1] += 1
	else:
		counts.append([el, 1])
	if n_increasing == 0 or increasing[-1] < el:
		increasing.append(el)
		n_increasing += 1
	elif n_decreasing == 0 or decreasing[-1] < el:
		decreasing.append(el)
		n_decreasing += 1
	else:
		raise ShouldNotGetHereException
if impossible:
	print('NO')
else:
	print('YES')
	print(n_increasing)
	print(*increasing)
	print(n_decreasing)
	decreasing.reverse()
	print(*decreasing)


n = int(input())
l = list(map(int, input().split()))
ai = []
d = []
l.sort()
c = 0
f = True
if n == 1:
	print('YES')
	print('0')
	print()
	print(1)
	print(l[0])
else:
	for i in range(1, len(l)):
		if l[i] == l[i - 1]:
			c += 1
		if c == 2:
			f = False
			break
		if l[i] != l[i - 1]:
			c = 0
	if f == False:
		print('NO')
	else:
		for j in range(n - 1):
			if l[j] == l[j + 1]:
				ai.append(l[j])
				d.append(l[j])
				j += 1
			else:
				d.append(l[j])
		if l[n - 1] != l[n - 2]:
			d.append(l[n - 1])
		d = set(d)
		print('YES')
		print(len(ai))
		print(*ai, end=' ')
		print()
		print(len(d))
		d = list(d)
		for k in range(len(d) - 1, -1, -1):
			print(d[k], end=' ')


n = int(input())
s = [int(x) for x in input().split()]
h1 = []
h2 = []
pos = [0] * 200005
temp = 0
for i in range(0, len(s)):
	if pos[s[i]] == 0:
		pos[s[i]] = pos[s[i]] + 1
		h1.append(s[i])
	elif pos[s[i]] == 1:
		pos[s[i]] = pos[s[i]] + 1
		h2.append(s[i])
	else:
		temp = 1
if temp == 1:
	print('NO')
else:
	h1 = sorted(h1)
	h2 = sorted(h2)
	h2 = h2[::-1]
	print('YES')
	print(len(h1))
	for j in range(0, len(h1)):
		print(h1[j], end=' ')
	print(' ')
	print(len(h2))
	for j in range(0, len(h2)):
		print(h2[j], end=' ')
	print(' ')


def main():
	n = int(input())
	a = list(map(int, input().split()))
	result = [0] * n
	last_increasing = -1
	last_decreasing = 200001
	for (i, x) in enumerate(a):
		if i == n - 1:
			if x < last_decreasing:
				result[i] = 1
			elif x <= last_increasing:
				print('NO')
				return
		else:
			if last_increasing >= x >= last_decreasing:
				print('NO')
				return
			if x > last_increasing and x >= last_decreasing:
				last_increasing = x
			if x <= last_increasing and x < last_decreasing:
				last_decreasing = x
				result[i] = 1
			if last_increasing < x < last_decreasing:
				if a[i + 1] > x:
					last_increasing = x
				else:
					last_decreasing = x
					result[i] = 1
	print('YES')
	print(' '.join(map(str, result)))
main()


n = int(input())
a = sorted(map(int, input().split()))
l1 = []
l2 = []
for i in a:
	if not l1:
		l1.append(i)
	elif l1[-1] == i:
		l2.append(i)
	else:
		l1.append(i)
if all((l1[i] > l1[i - 1] for i in range(1, len(l1)))) and all((l2[i] > l2[i - 1] for i in range(1, len(l2)))):
	print('YES')
	print(len(l2))
	print(*l2)
	print(len(l1))
	print(*l1[::-1])
else:
	print('NO')


n = int(input())
a = map(int, input().split())
x = set()
y = set()
for num in a:
	if num in x:
		if num in y:
			print('No')
			exit(0)
		else:
			y.add(num)
	else:
		x.add(num)
print('Yes')
for s in (sorted(x), sorted(y, reverse=True)):
	s = list(s)
	print(len(s))
	print(*s)


inc = []
dec = []
n = int(input())
num = [int(x) for x in input().split()]
pos = True
num.sort()
for i in num:
	if len(inc) == 0 or i > inc[-1]:
		inc.append(i)
	elif len(dec) == 0 or i > dec[-1]:
		dec.append(i)
	else:
		pos = False
if pos:
	print('YES')
	print(len(inc))
	for i in inc:
		print(i, end=' ')
	if len(inc) == 0:
		print()
	else:
		print()
	dec.sort(reverse=True)
	print(len(dec))
	for i in dec:
		print(i, end=' ')
	if len(dec) == 0:
		print()
	else:
		print()
else:
	print('NO')


n = input()
a = input().split()
a = [int(i) for i in a]
a.sort()
increasing = []
decreasing = []
rec = -1
times = 0
is_NO = False
for i in a:
	if rec == i:
		times = times + 1
	else:
		rec = i
		times = 0
	if times > 1:
		is_NO = True
		break
	elif times == 1:
		decreasing.append(i)
	else:
		increasing.append(i)
if is_NO:
	print('NO')
else:
	print('YES')
	print(len(increasing))
	increasing = [str(i) for i in increasing]
	print(' '.join(increasing))
	decreasing.reverse()
	decreasing = [str(i) for i in decreasing]
	print(len(decreasing))
	print(' '.join(decreasing))


n = int(input())
A = list(map(int, input().split()))
m1 = [float('-inf')]
m2 = [float('inf')]
ch = [0] * n
for i in range(n - 1):
	x = A[i]
	if m2[-1] > x > m1[-1]:
		if A[i + 1] > x:
			m1.append(x)
		else:
			m2.append(x)
			ch[i] = 1
	elif m2[-1] > x:
		m2.append(x)
		ch[i] = 1
	elif x > m1[-1]:
		m1.append(x)
	else:
		print('NO')
		exit(0)
i = n - 1
x = A[-1]
if m2[-1] > x > m1[-1]:
	pass
elif m2[-1] > x:
	m2.append(x)
	ch[i] = 1
elif x > m1[-1]:
	m1.append(x)
else:
	print('NO')
	exit(0)
print('YES')
print(*ch)


import sys
input = sys.stdin.readline
n = int(input())
l = list(map(int, input().split()))
ans = True
inc = list()
dec = list()
l.sort()
cnt = 0
for i in range(n - 1):
	if l[i] == l[i + 1]:
		dec.append(l[i])
		cnt += 1
	if cnt == 2:
		ans = False
		break
	if l[i] != l[i + 1]:
		cnt = 0
		inc.append(l[i])
inc.append(l[n - 1])
if ans:
	print('YES')
	print(len(inc))
	if inc == []:
		print()
	else:
		[print(i, end=' ') for i in inc]
		print()
	print(len(dec))
	if dec == []:
		print()
	else:
		[print(i, end=' ') for i in dec[::-1]]
		print()
else:
	print('NO')


n = int(input())
a = input().split()
for i in range(n):
	a[i] = int(a[i])
a.sort()
if len(a) == len(set(a)):
	print('YES')
	print(n)
	print(' '.join((str(x) for x in a)))
	print(0)
	print()
else:
	b = []
	j = 1
	while j < n:
		if a[j] == a[j - 1]:
			b.append(a[j])
			a.pop(j)
			n -= 1
			j -= 1
		j += 1
	b.sort(reverse=True)
	if len(b) == len(set(b)):
		print('YES')
		print(len(a))
		print(' '.join((str(x) for x in a)))
		print(len(b))
		print(' '.join((str(x) for x in b)))
	else:
		print('NO')


n = int(input(''))
a = input('').split()
count = [0 for _ in range(200001)]
bool_yes = True
inc = []
dec = []

def show_list(l):
	print(len(l))
	for item in l:
		print(str(item), end=' ')
	print()
for i in range(n):
	a[i] = int(a[i])
	count[a[i]] += 1
	if count[a[i]] > 2:
		bool_yes = False
if bool_yes:
	for i in range(200000, -1, -1):
		if count[i] == 2:
			dec.append(i)
			inc.append(i)
		if count[i] == 1:
			dec.append(i)
	inc.reverse()
	print('YES')
	show_list(inc)
	show_list(dec)
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
integ = 0
i = []
d = []
test = True
a.sort()
temi = -1
temd = -1
for j in a:
	if temi != j:
		i.append(j)
		temi = j
	elif temd != j:
		d.append(j)
		temd = j
	else:
		print('NO')
		test = False
		break
if test:
	print('YES')
	print(len(i))
	for j in range(len(i)):
		print(i[j], end=' ')
	print()
	print(len(d))
	for j in range(len(d) - 1, -1, -1):
		print(d[j], end=' ')


n = int(input())
a = list(map(int, input().split()))
s1 = set()
s2 = set()
ans = True
for i in a:
	if i not in s1:
		s1.add(i)
	elif i not in s2:
		s2.add(i)
	else:
		ans = False
		break
a.sort()
asc = []
desc = []
for (i, el) in enumerate(a):
	(asc, desc)[i & 1].append(el)
nasc = len(asc)
ndesc = len(desc)
desc = reversed(desc)
if ans:
	print('YES')
	print(nasc)
	print(' '.join(map(str, asc)))
	print(ndesc)
	print(' '.join(map(str, desc)))
else:
	print('NO')


n = int(input())
l = list(map(int, input().split()))
con = True
freq = [0] * 200001
for i in range(0, len(l)):
	freq[l[i]] += 1
	if freq[l[i]] > 2:
		con = False
		break
if con:
	inc = []
	dec = []
	for i in range(0, 200001):
		if freq[i] > 0:
			if freq[i] == 2:
				dec.append(i)
			inc.append(i)
	inc.sort()
	dec.sort(reverse=True)
	print('YES')
	print(len(inc))
	for i in range(0, len(inc)):
		print(inc[i], end=' ')
	print()
	print(len(dec))
	for i in range(0, len(dec)):
		print(dec[i], end=' ')
	print()
else:
	print('NO')


n = int(input())
arr = sorted(list(map(int, input().strip().split())))
a = arr[::2]
b = arr[1::2]
if len(set(a)) + len(set(b)) < len(arr):
	print('NO')
else:
	print('YES')
	print(len(a))
	print(*a)
	print(len(b))
	print(*b[::-1])


n = int(input())
a = list(map(int, input().split()))
b = sorted(a)
up = []
for_delete = []
for (idx, i) in enumerate(b):
	if not up:
		up.append(i)
		for_delete.append(idx)
	elif up[-1] != i:
		up.append(i)
		for_delete.append(idx)
	else:
		continue
for i in for_delete:
	b[i] = -1
new_a = []
for i in b:
	if i == -1:
		continue
	else:
		new_a.append(i)
if not new_a:
	print('YES')
	print(len(up))
	print(' '.join(map(str, up)))
	print(0)
	print()
	exit()
b = sorted(new_a, reverse=True)
down = []
for_delete = []
for (idx, i) in enumerate(b):
	if not down:
		down.append(i)
		for_delete.append(idx)
	elif down[-1] != i:
		down.append(i)
		for_delete.append(idx)
	else:
		continue
for i in for_delete:
	b[i] = -1
new_aa = []
for i in b:
	if i == -1:
		continue
	else:
		new_aa.append(i)
if not new_aa:
	print('YES')
	print(len(up))
	print(' '.join(map(str, up)))
	print(len(down))
	print(' '.join(map(str, down)))
else:
	print('NO')


n = input()
a = list(map(int, input().split()))
a.sort()
b = []
c = [a[0]]
ac = True
if len(a) >= 2:
	b.append(a[1])
for i in range(2, len(a)):
	if a[i] != a[i - 1]:
		b.append(a[i])
	elif c[len(c) - 1] != a[i]:
		c.append(a[i])
	else:
		ac = False
		break
if ac:
	print('YES')
	print(len(b))
	print(' '.join((str(i) for i in b)))
	c.reverse()
	print(len(c))
	print(' '.join((str(i) for i in c)))
else:
	print('NO')


n = int(input())
arr = sorted(list(map(int, input().split())))
c = 0
impossible = False
for i in range(1, len(arr)):
	if arr[i] == arr[i - 1]:
		c += 1
	else:
		c = 0
	if c == 2:
		impossible = True
		break
if impossible:
	print('NO')
else:
	inc = [arr[0]]
	dec = []
	for i in range(1, len(arr)):
		if arr[i] == arr[i - 1]:
			dec.append(arr[i])
		else:
			inc.append(arr[i])
	inc = list(map(str, inc))
	dec = list(map(str, dec))
	dec.reverse()
	print('YES')
	print(len(inc))
	print(' '.join(inc))
	print(len(dec))
	print(' '.join(dec))


import math
n = int(input())
a = list(map(int, input().split()))
a.sort()
q = [a[0]]
e = []
for i in range(1, n):
	if a[i] == a[i - 1]:
		if i >= 2:
			if a[i] == a[i - 2]:
				print('NO')
				break
			else:
				e.append(a[i])
		else:
			e.append(a[i])
	else:
		q.append(a[i])
else:
	q.sort()
	e.sort(reverse=True)
	print('YES')
	print(len(q))
	for i in range(len(q)):
		print(q[i], end=' ')
	print()
	print(len(e))
	for i in range(len(e)):
		print(e[i], end=' ')
	print()


n = int(input())
A = list(map(int, input().split()))
A.sort()
if len(set(A)) == n:
	print('YES')
	print(n)
	print(*A)
	print(0)
	print()
else:
	cnt = [0 for i in range(max(A) + 1)]
	a = 0
	for i in A:
		cnt[i] += 1
		a = max(a, cnt[i])
	if a >= 3:
		print('NO')
	else:
		print('YES')
		A = set(A)
		A = list(A)
		A.sort()
		print(len(A))
		print(*A)
		A.sort(reverse=True)
		print(n - len(A))
		for i in A:
			if cnt[i] == 2:
				print(i, end=' ')


from collections import defaultdict

def fun():
	return 0
n = int(input())
arr = [int(x) for x in input().split()]
arr = sorted(arr)
d = defaultdict(fun)
flag = True
for i in arr:
	d[i] += 1
	if d[i] > 2:
		flag = False
		break
if not flag:
	print('NO')
else:
	print('YES')
	dec = []
	dd = 0
	arr = sorted(set(arr))
	for i in arr:
		if d[i] == 2:
			dd += 1
			dec.append(i)
	print(dd)
	if dd == 0:
		print()
	else:
		for i in dec:
			print(i, end=' ')
		print()
	a = len(arr)
	print(a)
	if a == 0:
		print()
	else:
		for i in arr[::-1]:
			print(i, end=' ')
		print()


n = int(input())
l = list(map(int, input().split()))
ls = list(set(l))
l1 = [0] * 200004
l2 = []
l3 = []
for i in range(n):
	l1[l[i]] += 1
if max(l1) > 2:
	print('NO')
else:
	print('YES')
	for i in range(len(ls)):
		if l1[ls[i]] == 2:
			l2.append(ls[i])
			l3.append(ls[i])
		else:
			l2.append(ls[i])
	print(len(l2))
	if len(l2) > 0:
		l2.sort()
		for i in range(len(l2)):
			print(l2[i], end=' ')
	print()
	print(len(l3))
	if len(l3) > 0:
		l3.sort()
		for i in range(len(l3) - 1, -1, -1):
			print(l3[i], end=' ')
	print()


n = int(input())
l = list(map(int, input().split()))
l.sort()
d = {}
for i in l:
	d[i] = d.get(i, 0) + 1
l1 = list(d.values())
f = 1
for i in l1:
	if i > 2:
		f = 0
		break
if f == 0:
	print('NO')
else:
	print('YES')
	l1 = l[:n:2]
	l2 = l[1:n:2]
	print(len(l1))
	print(*l1)
	print(len(l2))
	print(*l2[::-1])


n = int(input())
arr = [int(x) for x in input().split()]
arr.sort()
a = []
b = []
poss = True
for i in range(len(arr)):
	if i == 0:
		a.append(arr[i])
	elif arr[i] != arr[i - 1]:
		a.append(arr[i])
	else:
		b.append(arr[i])
		if i > 1:
			if arr[i] == arr[i - 2]:
				poss = False
				break
c = b[::-1]
if poss == True:
	print('Yes')
	print(len(a))
	for i in range(len(a) - 1):
		print(a[i], end=' ')
	if len(a) != 0:
		print(a[len(a) - 1])
	print(len(c))
	for i in range(len(c) - 1):
		print(c[i], end=' ')
	if len(c) != 0:
		print(c[len(c) - 1])
else:
	print('No')


from collections import Counter, defaultdict
from math import factorial
n = int(input())
arr = [int(x) for x in input().split()]

def solve():
	c = defaultdict(int)
	for el in arr:
		c[el] += 1
		if c[el] > 2:
			print('NO')
			return
	a1 = []
	a2 = []
	for el in c:
		if c[el] == 2:
			a2.append(el)
		a1.append(el)
	print('YES')
	print(len(a1))
	a1.sort()
	print(*a1)
	print(len(a2))
	a2.sort(reverse=True)
	print(*a2)
solve()


n = int(input())
line = input().split()
arr = []
for i in range(n):
	arr.append(int(line[i]))
arr.sort()
flag = 0
current = arr[0]
dead = 0
extra = []
normal = []
for i in arr:
	if i == current:
		dead += 1
	else:
		dead = 1
		current = i
	if dead > 2:
		flag = 1
		break
	if dead == 1:
		extra.append(i)
	else:
		normal.append(i)
if flag == 1:
	print('NO')
else:
	print('YES')
	if len(extra) > 0:
		print(len(normal))
		for i in normal:
			print(i, end=' ')
		print('')
		print(len(extra))
		for i in extra[::-1]:
			print(i, end=' ')
		print('')
	else:
		print('0')
		print('')
		print(len(normal))
		for i in normal:
			print(i, end=' ')
		print('')


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def integer():
	return int(inp())

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def solve():
	n = int(inp())
	ar = lis()
	c = counter(ar)
	a1 = []
	a2 = []
	for i in c.keys():
		if c[i] >= 3:
			print('NO')
			exit()
		if c[i] == 2:
			a1.append(i)
			a2.append(i)
		else:
			a1.append(i)
	print('YES')
	a1.sort()
	a2.sort(reverse=True)
	print(len(a1))
	printlist(a1)
	print()
	print(len(a2))
	printlist(a2)
solve()


import sys
input = sys.stdin.readline
ins = lambda : input().rstrip()
ini = lambda : int(input().rstrip())
inm = lambda : map(int, input().rstrip().split())
inl = lambda : list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))
N = 2 * 10 ** 5 + 1
n = ini()
a = inl()
count = [0] * N
for i in a:
	count[i] += 1
if max(count) > 2:
	print('NO')
else:
	inc = []
	dec = []
	for i in range(N):
		if count[i] == 1:
			inc.append(i)
		elif count[i] == 2:
			inc.append(i)
			dec.insert(0, i)
	print('YES')
	print(len(inc))
	print(*inc)
	print(len(dec))
	print(*dec)


n = int(input())
a = list(map(int, input().split()))
ans1 = []
ans2 = []
b = {}
for i in a:
	if i in b:
		b[i] += 1
	else:
		b[i] = 1
for i in b:
	if b[i] > 2:
		print('NO')
		exit()
	elif b[i] == 2:
		ans1.append(i)
		ans2.append(i)
	else:
		ans1.append(i)
ans1.sort()
ans2.sort(reverse=True)
print('YES')
print(len(ans1))
print(*ans1)
print(len(ans2))
print(*ans2)


n = int(input())
l = [int(e.strip()) for e in input().strip().split()]
l = sorted(l)
inc = []
dec = []
las = -1
for pp in l:
	if pp != las:
		inc.append(pp)
		las = pp
	else:
		dec.append(pp)
dec = sorted(dec, reverse=1)
las = -1
ok = 1
for pp in dec:
	if pp == las:
		ok = 0
	las = pp
if ok == 0:
	print('NO')
else:
	print('YES')
	print(len(inc))
	for pp in inc:
		print(pp, end=' ')
	print('')
	print(len(dec))
	for pp in dec:
		print(pp, end=' ')


n = int(input())
a = list(map(int, input().split()))
a.sort()
a1 = []
a2 = []
l1 = 0
a1.append(a[0])
for i in range(1, n):
	if a[i] != a1[l1]:
		a1.append(a[i])
		l1 += 1
	else:
		a2.append(a[i])
for i in range(1, len(a2)):
	if a2[i] == a2[i - 1]:
		print('NO')
		exit()
if len(a1) + len(a2) != n:
	print('NO')
	exit()
a2.reverse()
print('YES')
print(len(a1))
print(*a1)
print(len(a2))
print(*a2)


def main():
	n = int(input())
	array = list(map(int, input().split()))
	inc = set()
	dec = set()
	impossible = False
	for i in array:
		if i not in inc:
			inc.add(i)
		elif i not in dec:
			dec.add(i)
		else:
			print('NO')
			return
	inc_arr = []
	for i in inc:
		inc_arr.append(i)
	dec_arr = []
	for i in dec:
		dec_arr.append(i)
	inc_arr.sort()
	dec_arr.sort(reverse=True)
	print('YES')
	print(len(inc_arr))
	if not inc_arr:
		print('')
	else:
		for i in inc_arr:
			print(i, end=' ')
		print()
	print(len(dec_arr))
	if not dec_arr:
		print('')
	else:
		for i in dec_arr:
			print(i, end=' ')
main()


from math import floor, ceil
n = int(input())
arr = sorted(list(map(int, input().split())))
a = arr[::2]
b = arr[1::2][::-1]
if len(set(a)) + len(set(b)) < len(arr):
	print('NO')
else:
	print(*['YES', len(a), *a, len(b), *b])


def input_ints():
	return list(map(int, input().split()))

def main():
	n = int(input())
	a = input_ints()
	x = []
	y = []
	a.sort()
	for p in a:
		if x and p == x[-1]:
			if y and p == y[-1]:
				print('No')
				return
			y.append(p)
		else:
			x.append(p)
	print('Yes')
	print(len(x))
	print(' '.join([str(a) for a in x]))
	print(len(y))
	print(' '.join([str(a) for a in y[::-1]]))
main()


from sys import stdin, stdout
from collections import Counter
st = lambda : list(stdin.readline().strip())
li = lambda : list(map(int, stdin.readline().split()))
mp = lambda : map(int, stdin.readline().split())
inp = lambda : int(stdin.readline())
pr = lambda n: stdout.write(str(n) + '\n')
mod = 1000000007

def solve():
	n = inp()
	l = li()
	d = Counter(l)
	for i in d:
		if d[i] > 2:
			pr('NO')
			return
	l.sort()
	x = []
	y = []
	for i in range(n):
		if i & 1:
			x.append(l[i])
		else:
			y.append(l[i])
	print('YES')
	print(len(x))
	print(*x)
	print(len(y))
	print(*y[::-1])
for _ in range(1):
	solve()


n = int(input())
s = input().split()
A = [int(i) for i in s]
A.sort()
num1 = []
num2 = []
possible = True
for i in A:
	if not num1 or i > num1[-1]:
		num1.append(i)
	elif not num2 or i > num2[-1]:
		num2.append(i)
	else:
		possible = False
		break
if not possible:
	print('NO')
else:
	print('YES')
	print(len(num2))
	for i in num2:
		print(i, end=' ')
	print()
	print(len(num1))
	for i in num1[::-1]:
		print(i, end=' ')


n = int(input())
a = [int(i) for i in input().split()]
a.sort()
ub = [None]
i = 1
res = True
while i < len(a):
	if a[i] == a[i - 1]:
		if a[i] == ub[-1]:
			res = False
			break
		else:
			ub.append(a.pop(i))
			i -= 1
	i += 1
ub.pop(0)
ub.reverse()
if not res:
	print('NO')
else:
	print('YES')
	print(len(a))
	print(' '.join(map(str, a)))
	print(len(ub))
	print(' '.join(map(str, ub)))


a = input()
b = input()
newlist = sorted([int(i) for i in b.split()])
dlist = []
ilist = []
dset = set()
iset = set()
countdict = dict()
flag = True
for i in newlist:
	if i not in countdict:
		countdict[i] = 1
	else:
		countdict[i] += 1
	if countdict[i] >= 3:
		flag = False
		print('No')
		break
if flag:
	for i in newlist:
		if i in iset:
			dset.add(i)
			dlist.append(i)
		else:
			iset.add(i)
			ilist.append(i)
	dlist = dlist[::-1]
	print('YES')
	print(len(ilist))
	print(*ilist)
	print(len(dlist))
	print(*dlist)


def process(A, n):
	B = {}
	for i in A:
		B[i] = B.get(i, 0) + 1
	flag = True
	for i in list(B.values()):
		if i > 2:
			flag = False
			break
	if flag == False:
		print('NO')
	else:
		C = []
		for i in B:
			if B[i] == 2:
				C.append(i)
		D = sorted(list(B.keys()), reverse=True)
		C.sort()
		print('YES')
		print(len(C))
		print(*C, sep=' ')
		print(len(D))
		print(*D, sep=' ')
n = int(input())
A = []
for x in input().split():
	A.append(int(x))
process(A, n)


def unMerge():
	n = int(input())
	L = list(map(int, input().rstrip().split()))
	L = sorted(L)
	L1 = []
	L2 = []
	for i in L:
		if not len(L1):
			L1.append(i)
			continue
		if i > L1[-1]:
			L1.append(i)
		elif not len(L2):
			L2.append(i)
		elif i > L2[-1]:
			L2.append(i)
		else:
			return []
	return [L2, list(reversed(L1))]
UM = unMerge()
if len(UM) != 2:
	print('NO', end='')
else:
	print('YES')
	print(len(UM[0]))
	print(' '.join(map(str, UM[0])))
	print(len(UM[1]))
	print(' '.join(map(str, UM[1])), end='')


def main():
	n = int(input())
	arr = list(map(int, input().split()))
	decr = set()
	incr = set()
	for i in range(n):
		val = arr.pop()
		if val not in decr:
			decr.add(val)
		elif val not in incr:
			incr.add(val)
		else:
			print('NO')
			return
	decr = sorted(list(decr), reverse=True)
	incr = sorted(list(incr))
	print('YES')
	print(len(incr))
	print(' '.join((str(x) for x in incr)))
	print(len(decr))
	print(' '.join((str(x) for x in decr)))
main()


def main():
	n = int(input())
	arr = sorted(list(map(int, input().split())))
	dec = []
	inc = []
	i = 0
	while i != n:
		if i + 2 < n and arr[i] == arr[i + 2]:
			print('NO')
			return 0
		if i + 1 < n and arr[i] == arr[i + 1]:
			dec.append(arr[i])
			i += 1
		inc.append(arr[i])
		i += 1
	print('YES')
	print(len(inc))
	print(*inc)
	print(len(dec))
	print(*dec[::-1])
	return 0
main()


import sys
n = int(input())
arr = list(map(int, input().split()))
noCounts = [0] * (2 * 10 ** 5 + 1)
increasing = []
for i in arr:
	noCounts[i] += 1
count1 = 0
count2 = 0
for i in range(200001):
	if noCounts[i] > 2:
		print('NO')
		sys.exit()
	elif noCounts[i] == 1:
		count1 += 1
	elif noCounts[i] == 2:
		count2 += 1
print('YES')
print(count2)
str1 = ''
for i in range(200001):
	if noCounts[i] == 2:
		noCounts[i] = 1
		str1 += str(i) + ' '
print(str1)
str1 = ''
print(count2 + count1)
for i in range(200000, -1, -1):
	if noCounts[i] == 1:
		str1 += str(i) + ' '
print(str1)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	n = I()
	c = collections.Counter(LI())
	a = []
	b = []
	for (k, v) in sorted(c.items()):
		if v > 2:
			return 'NO'
		a.append(k)
		if v > 1:
			b.append(k)
	return 'YES\n{}\n{}\n{}\n{}'.format(len(a), ' '.join(map(str, a)), len(b), ' '.join(map(str, b[::-1])))
print(main())


import sys
sys.setrecursionlimit(10 ** 5 + 1)
inf = int(10 ** 20)
max_val = inf
min_val = -inf
RW = lambda : sys.stdin.readline().strip()
RI = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]
nb_elements = RI()
elements = sorted(RMI())
if any((elements[i] == elements[i + 2] for i in range(nb_elements - 2))):
	print('NO')
else:
	print('YES')
	a = [x for x in elements[::2]]
	print(len(a))
	print(*a)
	a = [x for x in elements[1::2][::-1]]
	print(len(a))
	print(*a)


n = int(input())
ms = list(map(int, input().split()))
ms.sort()
voz = [ms[0]]
yb = [-1]
flag = True
for i in range(1, n):
	if voz[-1] != ms[i]:
		voz.append(ms[i])
	elif yb[-1] != ms[i]:
		yb.append(ms[i])
	else:
		flag = False
		break
if flag:
	del yb[0]
	yb.reverse()
	print('YES')
	print(len(voz))
	print(*voz)
	print(len(yb))
	print(*yb)
else:
	print('NO')


a1 = []
a = []
b = []
c = []
c1 = []
m = True
k = 0
n = int(input())
a1 = list(map(int, input().split()))
a = sorted(a1)
for i in range(n - 2):
	if a[i] == a[i + 1] and a[i + 1] == a[i + 2]:
		print('NO')
		m = False
		break
if m == True:
	for i in range(n - 1):
		if a[i] != a[i + 1] and a[i] != -1:
			b.append(a[i])
			a[i] = -1
		if a[i] == a[i + 1] and a[i] != -1:
			b.append(a[i])
			a[i] = -1
			c.append(a[i + 1])
			a[i + 1] = -1
	if len(a) > 1 and a[-1] != a[-2]:
		b.append(a[-1])
	if len(a) == 1:
		b.append(a[0])
c1 = sorted(c, reverse=True)
if m == True:
	print('YES')
	print(len(b))
	for i in range(len(b)):
		print(b[i], end=' ')
	print()
	print(len(c1))
	for i in range(len(c1)):
		print(c1[i], end=' ')


from sys import stdin
n = int(stdin.readline())
a = sorted(map(int, stdin.readline().split()), reverse=True)
one_map = set()
dec_val = set()
inc_val = set()
for i in a:
	if i in one_map:
		break
	if i not in dec_val:
		dec_val.add(i)
	elif i not in inc_val:
		inc_val.add(i)
	else:
		one_map.add(i)
if one_map:
	print('NO')
else:
	print('YES')
	if len(inc_val):
		print(len(inc_val))
		print(*sorted(inc_val))
	else:
		print(0)
		print()
	print(len(dec_val))
	print(*sorted(dec_val, reverse=True))


n = int(input())
arr = [int(p) for p in input().split()]
counter = {}
for i in range(len(arr)):
	try:
		counter[arr[i]] += 1
	except KeyError:
		counter[arr[i]] = 1
for i in counter:
	if counter[i] >= 3:
		print('NO')
		exit()
a = []
b = []
for i in counter:
	if counter[i] == 1:
		a.append(i)
		counter[i] -= 1
	else:
		a.append(i)
		b.append(i)
		counter[i] -= 2
a.sort()
b.sort(reverse=True)
print('YES')
print(len(a))
print(*a)
print(len(b))
print(*b)


from collections import Counter
import sys
n = int(input())
arr = list(map(int, input().split()))
numCount = Counter()
incline = []
ispossible = True
for num in arr:
	numCount[num] += 1
	if numCount[num] == 2:
		incline.append(num)
	elif numCount[num] == 3:
		print('NO')
		ispossible = False
		break
if not ispossible:
	sys.exit()
print('YES')
decline = list(numCount.keys())
decline.sort(reverse=True)
if len(incline) > 0:
	incline.sort()
print(len(incline))
for num in incline:
	print(num, end=' ')
print()
print(len(decline))
for num in decline:
	print(num, end=' ')
print()


n = int(input())
l = list(map(int, input().split()))
d = dict()
ubyv = []
vozr = []
o = 0
for i in l:
	d[i] = 0
for i in l:
	if d[i] == 0:
		d[i] = 1
		ubyv.append(i)
	elif d[i] == 1:
		d[i] = 2
		vozr.append(i)
	else:
		o = 1
		break
if o == 1:
	print('NO')
else:
	print('YES')
	print(len(vozr))
	vozr.sort()
	for i in vozr:
		print(i, end=' ')
	print()
	print(len(ubyv))
	ubyv.sort(reverse=True)
	for i in ubyv:
		print(i, end=' ')


from collections import Counter
n = int(input())
nums = [int(s) for s in input().split(' ')]
c = Counter(nums)
res = True
(one, two) = ([], [])
for num in c:
	one.append(num)
	if c[num] > 1:
		two.append(num)
	if c[num] > 2:
		res = False
		break
if res:
	one.sort()
	two.sort(reverse=True)
	print('YES')
	print(len(one))
	print(' '.join([str(s) for s in one]))
	print(len(two))
	print(' '.join([str(s) for s in two]))
else:
	print('NO')


N = int(input())
a = list(map(int, input().split()))
sa = sorted(a)
ma = {}
last = -1
for n in sa:
	if n in ma:
		if ma[n] == 2:
			print('no')
			exit(0)
		else:
			ma[n] += 1
	else:
		ma[n] = 1
fw = []
bw = []
for n in ma:
	if ma[n] == 2:
		fw.append(n)
		bw.append(n)
	else:
		fw.append(n)
print('yes')
print(len(fw))
print(*sorted(fw))
print(len(bw))
print(*sorted(bw, reverse=True))


import bisect
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
d = {}
for i in a:
	d[i] = 0
for i in a:
	d[i] += 1
for key in d:
	if d[key] >= 3:
		print('NO')
		exit()
if len(a) == 1:
	print('YES')
	print(1)
	print(a[0])
	print(0)
	print(' ')
else:
	l = list(set(a))
	c = []
	for i in range(len(l)):
		d[l[i]] -= 1
	for key in d:
		c += [key] * d[key]
	if len(c) != len(set(c)):
		print('NO')
	else:
		print('YES')
		print(len(l))
		print(*sorted(l))
		print(len(c))
		c = sorted(c)
		c.reverse()
		print(*c)


a = int(input())
b = list(map(int, input().split()))
b.sort(reverse=True)
c = [b[0]]
b[0] = -1
for j in range(1, a):
	if b[j] < c[-1]:
		c.append(b[j])
		b[j] = -1
d = list(set(b))
d.sort()
if d[0] == -1:
	d.remove(-1)
if len(d) + len(c) != a:
	print('NO')
else:
	print('YES')
	print(len(d))
	print(*d)
	print(len(c))
	print(*c)


input()
(X, Y) = (set(), set())
for a in map(int, input().split()):
	if a not in X:
		X.add(a)
	elif a not in Y:
		Y.add(a)
	else:
		print('NO')
		break
else:
	print('YES')
	print(len(X))
	print(*sorted(X))
	print(len(Y))
	print(*sorted(Y, reverse=True))


from collections import Counter
num = int(input())
arr = list(map(int, input().split()))
count = Counter(arr)
ans1 = []
ans2 = []
for (k, val) in count.items():
	if val > 2:
		print('NO')
		exit()
	elif val == 2:
		ans1.append(k)
		ans2.append(k)
	else:
		ans1.append(k)
print('YES')
print(len(ans1))
ans1.sort()
print(*ans1)
ans2 = sorted(ans2, reverse=True)
print(len(ans2))
print(*ans2)


input()
A = list(map(int, input().split()))
A.sort(reverse=True)
inc_seq = []
dec_seq = []
l = len(A)
len_inc = 0
l = len(A)
i = 0
while i < l:
	flag = 0
	if i < l - 2 and A[i] == A[i + 2]:
		flag = 1
		break
	elif i < l - 1 and A[i] == A[i + 1]:
		len_inc += 1
		inc_seq.insert(0, A[i])
		dec_seq.append(A[i])
		i += 2
	else:
		dec_seq.append(A[i])
		i += 1
if flag == 1:
	print('NO')
else:
	print('YES')
	print(len_inc)
	for num in inc_seq:
		print(num, end=' ')
	print()
	print(l - len_inc)
	for num in dec_seq:
		print(num, end=' ')


import sys
n = int(input())
a = [int(c) for c in input().split()]
a.sort()
if any((a[i] == a[i - 2] for i in range(2, n))):
	print('NO')
else:
	s1 = a[::2]
	s2 = a[1::2][::-1]
	print('YES')
	print(len(s1))
	print(*s1)
	print(len(s2))
	print(*s2)


z = input
n = int(z())
l = sorted(map(int, z().split()))
l1 = []
l1.append(l[0])
l2 = []
x = l[0]
for i in l[1:]:
	if i > x:
		l1.append(i)
		x = i
	else:
		l2.append(i)
t = 0
try:
	g = l2[0]
except:
	pass
for i in l2[1:]:
	try:
		if i <= g:
			t += 1
			break
		g = i
	except:
		pass
if t == 0:
	print('YES')
	print(len(l2))
	print(*l2)
	print(len(l1))
	print(*l1[::-1])
else:
	print('NO')


N = int(input())
k = [int(i) for i in input().split()]
inc = set()
dec = set()
flag = 'YES'
for i in range(N):
	temp = k.pop()
	if temp in dec and temp in inc:
		flag = 'NO'
		break
	elif temp in dec:
		inc.add(temp)
	else:
		dec.add(temp)
len_inc = len(inc)
if flag == 'YES':
	print(flag)
	print(len(inc))
	print(' '.join((str(i) for i in sorted(inc))))
	print(len(dec))
	print(' '.join((str(i) for i in sorted(dec)[::-1])))
else:
	print(flag)


n = int(input())
a = map(int, input().split())
count = [0 for x in range(2 * 10 ** 5 + 1)]
flag = False
for c in a:
	count[c] += 1
	if count[c] > 2:
		print('NO')
		flag = True
		break
if not flag:
	(a, b) = ([], [])
	(x, y) = (0, 0)
	for i in range(2 * 10 ** 5 + 1):
		if count[i]:
			a.append(i)
			x += 1
			count[i] -= 1
	for i in reversed(range(2 * 10 ** 5 + 1)):
		if count[i]:
			b.append(i)
			y += 1
	print('YES')
	print(x)
	print(*a)
	print(y)
	print(*b)


n = int(input())
a = list(map(int, input().split()))
a.sort()
Increase = []
Decrease = []
for i in range(len(a) - 1):
	if a[i] == a[i + 1] and a[i] != -1:
		Decrease.append(a[i + 1])
		a[i + 1] = -1
	if a[i] != -1:
		Increase.append(a[i])
if a[len(a) - 1] != -1:
	Increase.append(a[len(a) - 1])
Decrease = Decrease[::-1]
yes = True
for i in range(len(Decrease) - 1):
	if Decrease[i] == Decrease[i + 1]:
		yes = False
		break
for i in range(len(Increase) - 1):
	if Increase[i] == Increase[i + 1]:
		yes = False
		break
if yes:
	print('YES')
	print(len(Increase))
	for i in range(len(Increase)):
		print(Increase[i], end=' ')
	print()
	print(len(Decrease))
	for i in range(len(Decrease)):
		print(Decrease[i], end=' ')
	print()
else:
	print('NO')


n = int(input())
a = input().split()
for i in range(len(a)):
	a[i] = int(a[i])
a.sort()
inc = a[::2]
dec = a[1::2]
if len(set(inc)) + len(set(dec)) != n:
	print('NO')
else:
	print('YES')
	print(len(inc))
	for i in range(len(inc)):
		print(inc[i], end=' ')
	print()
	print(len(dec))
	for i in range(len(dec) - 1, -1, -1):
		print(dec[i], end=' ')


from collections import Counter
n = int(input())
arr = list(map(lambda x: int(x), input().split()))
c = Counter(arr)
if max([v for (k, v) in c.items()]) > 2:
	res = 'NO'
else:
	res = 'YES'
	arr = sorted(arr)
	(a, b) = ([], [])
	for (ind, elem) in enumerate(sorted(arr)):
		if ind % 2 == 0:
			a.append(str(elem))
		else:
			b.append(elem)
	b = sorted(b, reverse=True)
	b = list(map(lambda x: str(x), b))
if res == 'YES':
	print(res)
	print(len(a))
	print(' '.join(a))
	print(len(b))
	print(' '.join(b))
else:
	print(res)


n = input()
a = [int(x) for x in input().split()]
a = sorted(a)
b = []
c = []
ok = True
for i in range(len(a)):
	if i > 1:
		if a[i] == a[i - 1] and a[i - 1] == a[i - 2]:
			print('NO')
			ok = False
			break
	if i > 0 and a[i] == a[i - 1]:
		c.append(a[i])
	else:
		b.append(a[i])
if ok:
	c.reverse()
	print('YES')
	print(len(b))
	for i in b:
		print(i, end=' ')
	print()
	print(len(c))
	for i in c:
		print(i, end=' ')
	print()


n = int(input())
x = list(map(int, input().split()))
x = sorted(x)
a = []
b = []
a.append(x[0])
trigger = 0
for i in range(1, n):
	if x[i] != x[i - 1]:
		a.append(x[i])
		trigger = 0
	else:
		b.append(x[i])
		trigger += 1
	if trigger >= 2:
		break
if trigger < 2:
	print('YES')
	print(len(b))
	print(*b)
	print()
	print(len(a))
	c = []
	a = reversed(a)
	print(*a)
else:
	print('NO')


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')
	exit()
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 sys
import collections
from math import floor, ceil, log2
inp = lambda : sys.stdin.readline().strip()
n = int(inp())
a = [-1]
a = a + list(map(int, inp().split()))
a = sorted(a)
inc = []
dec = []
cnt = 0
for i in range(1, n + 1):
	if a[i - 1] != a[i]:
		cnt = 1
		inc.append(a[i])
	else:
		cnt += 1
		if cnt > 2:
			print('NO')
			sys.exit()
		dec.append(a[i])
print('YES')
print(len(inc))
for i in range(len(inc)):
	print(inc[i], end=' ')
print()
print(len(dec))
for i in range(1, len(dec) + 1):
	print(dec[-i], end=' ')


n = int(input())
a = [int(i) for i in input().split()]
co = {}
b = []
c = []
for i in range(len(a)):
	if a[i] not in co:
		co[a[i]] = 1
	else:
		co[a[i]] += 1
f = 1
for i in co:
	if co[i] > 2:
		f = 0
		break
	elif co[i] == 2:
		b.append(i)
		c.append(i)
	else:
		b.append(i)
b.sort()
c.sort(reverse=True)
if f == 0:
	print('NO')
else:
	print('YES')
	print(len(b))
	print(str(' '.join((str(i) for i in b))))
	print(len(c))
	print(str(' '.join((str(i) for i in c))))


def main():
	n = int(input())
	a = list(map(int, input().split()))
	ints = [0] * (2 * 10 ** 5 + 1)
	for i in a:
		ints[i] += 1
	inc = []
	dec = []
	for (i, value) in enumerate(ints):
		if value == 1:
			inc.append(i)
		elif value == 2:
			inc.append(i)
			dec.append(i)
		if value > 2:
			print('NO')
			return
	print('YES')
	print(len(inc))
	for i in inc:
		print(i, end=' ')
	print()
	print(len(dec))
	for i in reversed(dec):
		print(i, end=' ')
	print()
main()


n = int(input())
l = list(map(int, input().split()))
l.sort()
one = []
two = []
odd = True
No = False
for s in l:
	if odd:
		if one == [] or one[-1] != s:
			one.append(s)
		else:
			No = True
			break
		odd = False
	else:
		if two == [] or two[-1] != s:
			two.append(s)
		else:
			No = True
			break
		odd = True
if No:
	print('NO')
else:
	print('YES')
	print(len(one))
	for i in one:
		print(i, end=' ')
	print(len(two))
	for i in two[::-1]:
		print(i, end=' ')


from sys import stdin

def ip():
	return [int(i) for i in stdin.readline().split()]

def sp():
	return [str(i) for i in stdin.readline().split()]

def pp(A):
	for i in A:
		print(i)

def solve():
	n = int(input())
	A = ip()
	A.sort()
	(L, R) = ([A[0]], [])
	st = set({0})
	for i in range(1, len(A)):
		if A[i] == A[i - 1]:
			continue
		else:
			L.append(A[i])
			st.add(i)
	for i in range(len(A) - 1, -1, -1):
		if i in st:
			continue
		elif i == len(A) - 1:
			R.append(A[i])
		elif A[i] == A[i + 1]:
			continue
		else:
			R.append(A[i])
	if len(L) + len(R) != len(A):
		print('NO')
	else:
		print('YES')
		print(len(L))
		for i in L:
			print(str(i) + ' ', end='')
		print()
		print(len(R))
		for i in R:
			print(str(i) + ' ', end='')
	return 0
solve()


from collections import Counter
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)
if all((v <= 2 for v in C.values())):
	inc = []
	dec = []
	for (i, v) in C.items():
		inc.append(i)
		if v == 2:
			dec.append(i)
	inc = sorted(inc)
	dec = sorted(dec, reverse=True)
	print('Yes')
	print(len(inc))
	print(*inc)
	print(len(dec))
	print(*dec)
else:
	print('NO')
	exit()


n = int(input())
a = list(map(int, input().split()))
cnt = [0] * 200001
inc = []
dec = []
for x in a:
	cnt[x] += 1
if max(cnt) > 2:
	print('NO')
else:
	print('YES')
	for i in range(200001):
		if cnt[i] > 0:
			inc.append(i)
		if cnt[i] == 2:
			dec.append(i)
	print(len(inc))
	print(*sorted(inc))
	print(len(dec))
	print(*sorted(dec, reverse=True))


n = int(input())
l = list(map(int, input().split()))
a = []
b = []
dct = {}
ans = 'YES'
for i in l:
	if i in dct:
		dct[i] += 1
	else:
		dct[i] = 1
for i in dct:
	if dct[i] > 2:
		ans = 'NO'
	elif dct[i] == 2:
		a.append(i)
		b.append(i)
	else:
		a.append(i)
print(ans)
if ans == 'YES':
	a.sort()
	print(len(a))
	for i in a:
		print(i, end=' ')
	print('')
	b.sort(reverse=True)
	print(len(b))
	for i in b:
		print(i, end=' ')


import sys
from collections import Counter, deque

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST():
	return list(map(int, input().split()))

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
N = INT()
A = LIST()
C = Counter(A)
asc = deque()
desc = deque()
for (k, v) in sorted(C.items()):
	if v >= 3:
		NO()
		exit()
	elif v == 2:
		asc.append(k)
		desc.appendleft(k)
	elif v == 1:
		asc.append(k)
YES()
print(len(asc))
print(*asc)
print(len(desc))
print(*desc)


import sys, collections
elements = input()
numbers = map(int, input().split())
freqs = {}
for number in list(numbers):
	if number in freqs:
		freqs[number] += 1
	else:
		freqs[number] = 1
	if freqs[number] > 2:
		print('NO')
		sys.exit()
keys = list(freqs.keys())
keys.sort()
ascending_list = collections.deque()
descending_list = collections.deque()
for key in keys:
	if freqs[key] == 1:
		ascending_list.append(key)
	else:
		ascending_list.append(key)
		descending_list.appendleft(key)
print('YES')
print(len(ascending_list))
print(' '.join(map(str, ascending_list)))
print(len(descending_list))
print(' '.join(map(str, descending_list)))


n = int(input())
a = list(map(int, input().split()))
a.sort()
l1 = []
l2 = []
for i in range(n):
	if i % 2 == 0:
		l1.append(a[i])
	else:
		l2.append(a[i])
l1.sort()
l2 = sorted(l2, reverse=True)
fl = 0
for i in range(len(l1) - 1):
	if l1[i] == l1[i + 1]:
		fl = 1
		break
for i in range(len(l2) - 1):
	if l2[i] == l2[i + 1]:
		fl = 1
		break
if fl == 1:
	print('NO')
else:
	print('YES')
	print(len(l1))
	for i in range(len(l1)):
		print(l1[i], end=' ')
	print()
	print(len(l2))
	for i in range(len(l2)):
		print(l2[i], end=' ')
	print()


n = int(input())
l = list(map(int, input().split()))
l.sort()
inc = []
dec = []
if n == 1:
	print('YES')
	print(len(inc))
	print(*inc)
	print(len(l))
	print(*l)
elif n == 2:
	print('YES')
	print(1)
	print(l[0])
	print(1)
	print(l[1])
elif len(set(l)) == 1:
	print('NO')
else:
	set1 = set()
	set2 = set()
	for i in l:
		if i not in set1:
			set1.add(i)
		else:
			set2.add(i)
	if len(set1) + len(set2) != n:
		print('NO')
	else:
		print('YES')
		print(len(set1))
		print(*sorted(list(set1)))
		k = list(set2)
		k.sort(reverse=True)
		print(len(k))
		print(*k)


from sys import stdin, stdout
for _ in range(1):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	inc = []
	dec = []
	a.sort(reverse=True)
	dec += [a[0]]
	for i in range(1, n):
		if a[i] == a[i - 1]:
			inc += [a[i]]
		else:
			dec += [a[i]]
	if len(set(inc)) != len(inc):
		print('NO')
		continue
	else:
		print('YES')
		print(len(inc))
		inc.sort()
		print(*inc)
		print(len(dec))
		print(*dec)


n = int(input())
l = list(map(int, input().split()))
l.sort()
asc = []
desc = []
prev_diff = -1
l = l + [2 * 10 ** 5 + 1]
for i in range(len(l) - 1):
	curr_diff = l[i + 1] - l[i]
	if prev_diff == 0 and curr_diff == 0:
		print('NO')
		break
	if l[i + 1] > l[i]:
		asc.append(l[i])
	else:
		desc.append(l[i])
	prev_diff = curr_diff
else:
	print('YES')
	print(len(desc))
	print(*sorted(desc))
	print(len(asc))
	print(*sorted(asc, reverse=True))


a = int(input())
nums = map(int, input().split(' '))

def calc(a, nums):
	inc = []
	dec = []
	usedInInc = set()
	usedInDec = set()
	for i in sorted(nums):
		if not i in usedInInc:
			inc.append(i)
			usedInInc.add(i)
		elif not i in usedInDec:
			dec.append(i)
			usedInDec.add(i)
		else:
			print('NO')
			return
	print('YES')
	print(len(inc))
	print(' '.join((str(e) for e in inc)))
	print(len(dec))
	print(' '.join((str(e) for e in sorted(dec, reverse=True))))
calc(a, nums)


n = int(input())
a = sorted(map(int, input().split()))
(n1, n2) = ([], [])
for (i, el) in enumerate(a):
	if i > 1 and el == a[i - 1] == a[i - 2]:
		print('NO')
		exit()
	if el == a[i - 1]:
		n2.append(el)
	else:
		n1.append(el)
print('YES')
print(len(n1))
print(' '.join([str(n) for n in n1]))
print(len(n2))
print(' '.join(reversed([str(n) for n in n2])))


n = int(input())
a = [int(i) for i in input().split()]
inc = []
dec = []
f = True
d = dict(((i, 0) for i in a))
for i in a:
	d[i] += 1
for i in d:
	if d[i] > 2:
		f = False
		break
	elif d[i] == 2:
		inc.append(i)
		dec.append(i)
	else:
		dec.append(i)
if f:
	print('YES')
	print(len(inc))
	inc.sort()
	print(*inc)
	print(len(dec))
	dec.sort(reverse=True)
	print(*dec)
else:
	print('NO')


from collections import Counter
n = int(input())
l = [int(x) for x in input().split()]
count = Counter(l)
if any((v > 2 for v in count.values())):
	print('NO')
else:
	l_asc = sorted([k for (k, v) in count.items() if v == 2])
	l_des = sorted([k for (k, v) in count.items()], reverse=True)
	print('YES')
	print(len(l_asc))
	print(*(l_asc if len(l_asc) > 0 else ''))
	print(len(l_des))
	print(*(l_des if len(l_des) > 0 else ''))


n = int(input())
A = list(map(int, input().split()))
A.sort()
inc = [A[0]]
a = A[0]
count = 1
dec = []
for i in range(1, n):
	if a == A[i]:
		count += 1
		dec.append(A[i])
	else:
		inc.append(A[i])
		count = 1
		a = A[i]
	if count == 3:
		break
if count == 3:
	print('No')
else:
	print('Yes')
	print(len(inc))
	print(*inc)
	print(len(dec))
	dec.sort(reverse=True)
	print(*dec)


def func():
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	set_arr = set(arr)
	temp = [0 for i in range(arr[-1] + 1)]
	for i in arr:
		temp[i] += 1
	for i in temp:
		if i > 2:
			print('No')
			return 0
	inc = [i for i in range(arr[-1] + 1) if temp[i] > 1]
	dec = [i for i in range(arr[-1], -1, -1) if temp[i]]
	print('Yes')
	print(len(inc))
	for i in inc:
		print(i, end=' ')
	print('')
	print(len(dec))
	for i in dec:
		print(i, end=' ')
func()


n = int(input())
s = input().split()
a = []
i = 0
for i in s:
	a.append(int(i))
a.sort()
flag = 1
for i in range(1, n - 1):
	if a[i] == a[i - 1] and a[i] == a[i + 1]:
		flag = 0
		print('NO')
		break
if flag == 1:
	print('YES')
	a1 = []
	a2 = []
	f = 0
	for i in range(n):
		if i % 2 == f:
			a1.append(a[i])
		else:
			a2.append(a[i])
	if len(a1) > 0:
		print(len(a1))
		print(*a1, sep=' ')
	if len(a1) == 0:
		print(0)
		print('\n')
	if len(a2) > 0:
		a2.reverse()
		print(len(a2))
		print(*a2, sep=' ')
	if len(a2) == 0:
		print(0)
		print('\n')


import sys
n = int(input())
l = list(map(int, input().split()))
a = set()
b = set()
for i in range(len(l)):
	if l[i] not in a:
		a.add(l[i])
	elif l[i] not in b:
		b.add(l[i])
	else:
		print('NO')
		sys.exit()
print('YES')
print(len(a))
print(*sorted(a))
print(len(b))
print(*sorted(b, reverse=True))


n = int(input())
ar = list(map(int, input().split(' ')))
ar.sort()
c = 0
inc = [ar[0]]
dec = []
for i in range(1, n):
	if ar[i] != inc[-1]:
		inc.append(ar[i])
	elif ar[i] == inc[-1]:
		if len(dec) == 0:
			dec.append(ar[i])
		elif len(dec) > 0 and dec[-1] != ar[i]:
			dec.append(ar[i])
		else:
			c = 1
			break
if c == 0:
	print('YES')
	print(len(inc))
	print(' '.join(map(str, inc)))
	print(len(dec))
	print(' '.join(map(str, dec[::-1])))
else:
	print('NO')


n = int(input())
arr = (int(i) for i in input().split(' '))
temp = {}
for i in arr:
	if i not in temp:
		temp[i] = 0
	temp[i] += 1
for value in temp.values():
	if value > 2:
		print('No')
		exit()
print('Yes')
a = []
for key in sorted(temp.keys()):
	a.append(key)
	temp[key] -= 1
print(len(a))
print(' '.join((str(i) for i in a)))
b = []
for key in reversed(sorted(temp.keys())):
	if temp[key] > 0:
		b.append(key)
print(len(b))
print(' '.join((str(i) for i in b)))


import sys
import random

class Main:

	def __init__(self):
		self.buff = None
		self.index = 0

	def next(self):
		if self.buff is None or self.index == len(self.buff):
			self.buff = sys.stdin.readline().split()
			self.index = 0
		val = self.buff[self.index]
		self.index += 1
		return val

	def next_int(self):
		return int(self.next())

	def solve(self):
		n = self.next_int()
		x = sorted([self.next_int() for _ in range(0, n)])
		a = []
		b = []
		for d in x:
			if len(a) == 0 or a[-1] != d:
				a.append(d)
			elif len(b) == 0 or b[-1] != d:
				b.append(d)
			else:
				print('NO')
				return
		print('YES')
		print(len(a))
		print(' '.join(map(lambda x: str(x), a)))
		print(len(b))
		print(' '.join(map(lambda x: str(x), b[::-1])))
Main().solve()


from collections import Counter
n = int(input())
l = list(map(int, input().split()))
g = Counter(l)
li = []
ni = 0
ld = []
nd = 0
flag = 0
for i in g:
	if g[i] == 2:
		li.append(i)
		ld.append(i)
		ni += 1
		nd += 1
	elif g[i] == 1:
		ld.append(i)
		nd += 1
	else:
		flag = 1
		break
if flag == 1:
	print('NO')
else:
	print('YES')
	print(ni)
	li.sort()
	ld.sort(reverse=True)
	for j in range(ni):
		if j != ni - 1:
			print(li[j], end=' ')
		else:
			print(li[j])
	if ni == 0:
		print('')
	print(nd)
	for j in range(nd):
		print(ld[j], end=' ')


n = int(input())
a = list(map(int, input().split()))
dic = {}
can = 1
inc = []
dec = []
for i in a:
	if i not in dic:
		dic[i] = 1
	else:
		dic[i] += 1
		if dic[i] > 2:
			can = 0
			break
		elif dic[i] == 2:
			inc.append(i)
if can == 0:
	print('NO')
else:
	print('YES')
	dec = sorted(list(set(a)), reverse=1)
	inc = sorted(inc)
	print(len(inc))
	print(' '.join(map(str, inc)))
	print(len(dec))
	print(' '.join(map(str, dec)))


import sys
import math
import heapq
import bisect
from collections import defaultdict as dd
f = dd(int)
n = int(input())
l = [int(i) for i in input().split()]
inc = []
dec = []
for i in l:
	f[i] += 1
c = 0
for i in f:
	if f[i] > 2:
		c = 1
if c:
	print('NO')
else:
	for i in f:
		if f[i] == 1:
			inc.append(i)
		else:
			inc.append(i)
			dec.append(i)
	inc.sort()
	dec.sort(reverse=1)
	print('YES')
	print(len(inc))
	print(*inc)
	print(len(dec))
	print(*dec)


n = input()
nums = input().split()
nums = list(map(int, nums))
nums.sort()
count = {}
res1 = []
res2 = []
flag = True
for i in nums:
	count1 = count.get(i, 0)
	if count1 == 0:
		count[i] = 1
		res1.append(i)
	elif count1 == 1:
		count[i] = 2
		res2.append(i)
	else:
		print('NO')
		flag = False
		break
if flag:
	print('YES')
	print(len(res1))
	res1 = list(map(str, res1))
	print(' '.join(res1))
	print(len(res2))
	res2.reverse()
	res2 = list(map(str, res2))
	print(' '.join(res2))


n = int(input())
a = list(map(int, input().split()))
a.sort()
b = set(a)
f = 0
d = {}
for i in a:
	if i not in d:
		d[i] = 1
	else:
		d[i] += 1
for i in b:
	if d[i] > 2:
		f = 1
		break
w = []
for i in b:
	if d[i] == 2:
		w.append(i)
if f == 0:
	b = sorted(b, reverse=True)
	w = sorted(w)
	print('YES')
	print(len(w))
	print(*w)
	print(len(b))
	print(*b)
else:
	print('NO')


from collections import Counter
n = int(str(input()).strip())
arr = [int(x) for x in str(input()).strip().split(' ')]
arr = list(sorted(arr))
cnt = Counter(arr)
if any((v > 2 for v in cnt.values())):
	print('NO')
else:
	inc = []
	dec = []
	for a in arr:
		if not inc or a > inc[-1]:
			inc.append(a)
		else:
			dec.append(a)
	print('YES')
	print(len(inc))
	print(' '.join([str(x) for x in inc]))
	dec.reverse()
	print(len(dec))
	print(' '.join([str(x) for x in dec]))


n = int(input())
a = list(map(int, input().split()))
p = [0] * (2 * 10 ** 5 + 1)
for i in a:
	p[i] = p[i] + 1
if max(p) > 2:
	print('NO')
else:
	inc = []
	dec = []
	for i in range(0, len(p)):
		if p[i] >= 1:
			inc.append(i)
		if p[i] == 2:
			dec.append(i)
	print('YES')
	print(len(dec))
	for i in dec:
		print(i, end=' ')
	print()
	inc = inc[::-1]
	print(len(inc))
	for i in inc:
		print(i, end=' ')


n = int(input())
a = sorted(map(int, input().split()))
(inc, dec) = ([], [])
for a_i in a:
	if len(inc) > 0 and len(dec) > 0 and (inc[-1] == a_i) and (dec[-1] == a_i):
		print('NO')
		break
	elif len(inc) > 0 and inc[-1] == a_i:
		dec.append(a_i)
	else:
		inc.append(a_i)
else:
	print('YES')
	print(len(inc))
	print(' '.join(map(str, inc)))
	print(len(dec))
	print(' '.join(map(str, reversed(dec))))


import sys
from collections import Counter
n = int(input())
c = list(map(int, input().split()))
d = Counter(c)
l1 = []
l2 = []
for (key, value) in d.items():
	if value >= 3:
		print('NO')
		sys.exit()
	if value == 2:
		l1.append(key)
		l2.append(key)
	else:
		l1.append(key)
print('YES')
print(len(l1))
print(*sorted(l1))
print(len(l2))
print(*sorted(l2)[::-1])


from collections import deque
n = int(input())
a = [int(x) for x in input().split()]
a.sort()
inc = [a[0]]
dec = deque()
for i in range(1, n):
	if a[i - 1] == a[i]:
		if i + 1 < n and a[i] == a[i + 1]:
			break
		dec.appendleft(a[i])
	else:
		inc.append(a[i])
else:
	linc = len(inc)
	ldec = len(dec)
	print('Yes')
	print(linc)
	for x in inc:
		print(x, end=' ')
	print()
	print(ldec)
	for x in dec:
		print(x, end=' ')
	exit()
print('No')


n = int(input())
array = input().split(' ')
dec = []
inc = []
for i in range(n):
	array[i] = int(array[i])
array.sort()
check = 0
for i in range(1, n):
	if check == 2:
		print('NO')
		break
	if int(array[i - 1]) == int(array[i]):
		check += 1
	else:
		check = 0
if check != 2:
	for i in range(0, n - 1):
		if int(array[i]) != int(array[i + 1]):
			inc.append(int(array[i]))
		else:
			dec.append(int(array[i]))
	if int(array[n - 1]) != int(array[n - 2]):
		dec.append(int(array[n - 1]))
	else:
		inc.append(int(array[n - 1]))
	print('YES')
	print(len(inc))
	for i in range(0, len(inc)):
		print(inc[i], end=' ')
	print('')
	print(len(dec))
	for i in range(len(dec) - 1, -1, -1):
		print(dec[i], end=' ')


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')
		sys.exit()
	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=' ')


def solve(a):
	d = {}
	for i in a:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	for i in d:
		if d[i] > 2:
			print('NO')
			return
	print('YES')
	inc = []
	dec = []
	for i in d:
		if d[i] == 2:
			inc.append(i)
			dec.append(i)
		else:
			inc.append(i)
	inc.sort()
	dec.sort(reverse=True)
	print(len(inc))
	if len(inc) == 0:
		print('\n')
	else:
		print(*inc)
	print(len(dec))
	if len(dec) == 0:
		print('\n')
	else:
		print(*dec)
n = int(input())
x = input().split()
a = []
for i in x:
	a.append(int(i))
solve(a)


from collections import *
input()
a = Counter(map(int, input().split()))
if max(a.values()) > 2:
	print('NO')
	exit()
b = sorted((x for x in a if a[x] > 1))[::-1]
print('YES', len(a), *sorted(a), len(b), *b)


n = int(input())
v = sorted((int(x) for x in input().split()))

def solve(v):
	asc = [v[0]]
	desc = []
	for n in v[1:]:
		if asc[-1] == n:
			if desc and desc[-1] == n:
				print('NO')
				return
			desc.append(n)
		else:
			asc.append(n)
	print('YES')
	print(len(asc))
	print(' '.join(map(str, asc)))
	print(len(desc))
	desc.reverse()
	print(' '.join(map(str, desc)))
solve(v)


import math

def main():
	n = int(input())
	a = list(map(int, input().split()))
	if n == 1:
		print('YES')
		print(0)
	else:
		res = [0] * n
		ok = True
		last_inc = -math.inf
		last_dec = math.inf
		for i in range(n):
			if a[i] > last_inc and a[i] >= last_dec:
				res[i] = 0
				last_inc = a[i]
			elif a[i] < last_dec and a[i] <= last_inc:
				res[i] = 1
				last_dec = a[i]
			elif last_dec <= a[i] <= last_inc:
				ok = False
				break
			elif i < n - 1:
				next_val = a[i + 1]
				if next_val >= a[i]:
					res[i] = 0
					last_inc = a[i]
				else:
					res[i] = 1
					last_dec = a[i]
			else:
				res[i] = 0
				last_inc = a[i]
		if not ok:
			print('NO')
		else:
			print('YES')
			print(' '.join(map(str, res)))
main()


BS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def to_base(s, b):
	res = ''
	while s:
		res += BS[s % b]
		s //= b
	return res[::-1] or '0'
alpha = 'abcdefghijklmnopqrstuvwxyz'
n = int(input())
nums = list(map(int, input().split()))
from collections import Counter
c = Counter(nums)
ans = True
asc = set()
desc = set()
done = set()
for j in c:
	if c[j] > 2:
		ans = False
		break
	elif c[j] == 2:
		asc.add(j)
		desc.add(j)
		done.add(j)
if not ans:
	print('NO')
else:
	print('YES')
	desc = sorted(desc, reverse=True)
	asc |= set(nums) - done
	asc = sorted(asc)
	print(len(asc))
	print(' '.join(list(map(str, asc))))
	print(len(desc))
	print(' '.join(list(map(str, desc))))


n = int(input())
s1 = []
s2 = []
a = list(map(int, input().split()))
a.sort()
fuck = len(a)
s1.append(a[0])
l1 = 1
l2 = 0
a[0] = -1
for i in range(n):
	if a[i] > s1[l1 - 1] and a[i] != -1:
		s1.append(a[i])
		l1 += 1
		a[i] = -1
for i in range(n):
	if a[i] != -1:
		s2.append(a[i])
		l2 += 1
s2.sort()
s2.reverse()
count = 0
for i in range(l2 - 1):
	if s2[i] > s2[i + 1]:
		count += 1
t = 0
if fuck == l1:
	t = 1
elif fuck == l2:
	t = 1
elif count == l2 - 1:
	if l1 + l2 == fuck:
		t = 1
if t:
	print('YES')
	print(l1)
	print(*s1)
	print(l2)
	print(*s2)
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
a.sort()
o_1 = []
o_2 = []
for i in range(n - 2):
	if a[i] == a[i + 1] and a[i] == a[i + 2]:
		print('NO')
		exit()
for i in range(n - 1):
	if a[i] == a[i + 1]:
		o_2.append(-a[i])
	else:
		o_1.append(a[i])
o_1.append(a[n - 1])
print('YES')
print(len(o_1))
print(*o_1)
print(len(o_2))
o_2.sort()
for i in range(len(o_2)):
	print(-o_2[i], end=' ')


n = int(input())
a = [*map(int, input().split())]
a1 = set()
b1 = set()
for i in a:
	if i not in a1:
		a1.add(i)
	else:
		b1.add(i)
if len(a1) + len(b1) == n:
	b1 = list(b1)
	a1 = list(a1)
	b1.sort()
	b1 = b1[::-1]
	print('YES')
	print(len(a1))
	a1.sort()
	print(*a1)
	print(len(b1))
	print(*b1)
else:
	print('NO')


n = int(input())
x = sorted(list(map(int, input().split())))
cur_cnt = 1
(a, b) = ([], [])
if n == 1:
	a.append(x[0])
for i in range(1, n):
	if cur_cnt == 3:
		print('NO')
		exit()
	if x[i] == x[i - 1]:
		cur_cnt += 1
	elif x[i] != x[i - 1]:
		if cur_cnt == 1:
			a.append(x[i - 1])
		elif cur_cnt == 2:
			a.append(x[i - 1])
			b.append(x[i - 1])
		cur_cnt = 1
	if i == n - 1:
		if cur_cnt == 1:
			a.append(x[i])
		elif cur_cnt == 2:
			a.append(x[i])
			b.append(x[i])
print('YES')
print(len(a))
print(*sorted(a))
print(len(b))
print(*sorted(b, reverse=True))


from collections import deque

def decouple_seq(seq):
	seq.sort(reverse=True)
	increasing = deque()
	decreasing = deque()
	for n in seq:
		if not increasing or n < increasing[0]:
			increasing.appendleft(n)
			continue
		elif not decreasing or n < decreasing[-1]:
			decreasing.append(n)
			continue
		print('NO')
		return
	print('YES')
	print(len(increasing))
	print(' '.join(map(str, increasing)))
	print(len(decreasing))
	print(' '.join(map(str, decreasing)))
_ = input()
sequence = [int(num) for num in input().split()]
decouple_seq(sequence)


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)


from collections import Counter, deque
n = int(input())
l = list(map(int, input().split()))
cc = Counter(l)
vals = set(cc.values())
if max(vals) > 2:
	print('NO')
	exit()
print('YES')
decres = deque()
set_ = sorted(set(l))
for i in set_:
	if cc[i] == 2:
		decres.appendleft(i)
print(len(set_))
print(*set_)
print(len(decres))
print(*decres)


from collections import defaultdict
n = int(input().strip())
nums = defaultdict(int)
for num in input().strip().split():
	num = int(num)
	nums[num] += 1
(asc, desc) = ([], [])
impossible = False
for k in sorted(nums.keys()):
	if nums[k] > 2:
		impossible = True
		break
	elif nums[k] == 1:
		asc.append(k)
	else:
		asc.append(k)
		desc.append(k)
if impossible:
	print('NO')
else:
	print('YES')
	print(len(asc))
	print(' '.join(map(str, asc)) if asc else '')
	print(len(desc))
	print(' '.join(map(str, reversed(desc))) if desc else '')


n = int(input())
d = {}
ar = sorted(list(map(int, input().split())))
for i in ar:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
if max(d.values()) > 2:
	print('NO')
else:
	ar1 = ar[::2]
	ar2 = ar[1::2]
	print('YES')
	print(len(ar1))
	print(*ar1)
	print(len(ar2))
	print(*ar2[::-1])


n = int(input())
l1 = [int(x) for x in input().split()]
l2 = l1.copy()
l2.sort()
targ = l2[0]
i = 1
first = [targ]
l2[0] = -1
while i < len(l2):
	if l2[i] > targ:
		first.append(l2[i])
		targ = l2[i]
		l2[i] = -1
	i += 1
l2 = [x for x in l2 if x != -1]
if l2:
	targ = l2[0]
	i = 1
	second = [targ]
	l2[0] = -1
	while i < len(l2):
		if l2[i] > targ:
			second.append(l2[i])
			targ = l2[i]
			l2[i] = -1
		i += 1
	l2 = [x for x in l2 if x != -1]
	if not l2:
		print('YES')
		print(len(first))
		print(*first)
		print(len(second))
		second.reverse()
		print(*second)
	else:
		print('NO')
else:
	print('YES')
	print(len(first))
	print(*first)
	print(0)
	print()


from collections import Counter
N = int(input())
ls = list(map(int, input().split()))
d = dict(Counter(ls))
for i in ls:
	if d[i] > 2:
		print('NO')
		break
else:
	print('YES')
	inc = []
	dec = []
	ls = list(set(ls))
	for i in ls:
		if d[i] == 2:
			inc.append(i)
		dec.append(i)
	inc.sort()
	dec.sort()
	dec.reverse()
	print(len(inc))
	for i in inc:
		print(i, end=' ')
	print()
	print(len(dec))
	for i in dec:
		print(i, end=' ')
	print()


n = int(input())
a = map(int, input().split())
inc = [-1 for i in range(200001)]
dec = [-1 for i in range(200001)]
li = 0
result = 'Yes'
for number in a:
	if inc[number] == number:
		if dec[number] == number:
			result = 'No'
			break
		else:
			dec[number] = number
	else:
		inc[number] = number
		li += 1
if result == 'No':
	print('No')
else:
	print('Yes')
	if li > 0:
		print(li)
		incstr = ''
		for number in inc:
			if number != -1:
				incstr += str(number) + ' '
		print(incstr[:-1])
	else:
		print('0')
		print()
	if n - li > 0:
		print(n - li)
		decstr = ''
		for number in dec:
			if number != -1:
				decstr = str(number) + ' ' + decstr
		print(decstr[:-1])
	else:
		print('0')
		print()


n = int(input())
t = list(map(int, input().split(' ')))
sorted(t)
(temp, temp2) = (-1, -1)
ans = 'Yes'
(l, m) = (set(), set())
for x in t:
	if x not in l:
		l.add(x)
	elif x not in m:
		m.add(x)
	else:
		ans = 'No'
		print('No')
		break
if ans == 'Yes':
	print(ans)
	print(len(l))
	if l:
		print(' '.join(map(str, sorted(l))))
	else:
		print()
	print(len(m))
	if m:
		print(' '.join(map(str, sorted(m)[::-1])))
	else:
		print()


numero = int(input())
lista = [int(x) for x in input().split()]
lista2 = []
lista.sort()
i = 0
while True:
	if i > len(lista) - 1:
		break
	if len(lista) - i > 2:
		if lista[i] == lista[i + 1] and lista[i] == lista[i + 2]:
			print('No')
			quit()
		elif lista[i] == lista[i + 1]:
			lista2.append(lista[i])
			del lista[i]
			i += 1
			continue
		else:
			i += 1
			continue
	if len(lista) - i > 1:
		if lista[i] == lista[i + 1]:
			lista2.append(lista[i])
			del lista[i]
			break
	i += 1
lista2.sort(reverse=True)
print('Yes')
print(len(lista))
if len(lista) > 0:
	print(lista[0], end='')
for i in range(1, len(lista)):
	print(' ', end='')
	print(lista[i], end='')
print()
print(len(lista2))
if len(lista2) > 0:
	print(lista2[0], end='')
for i in range(1, len(lista2)):
	print(' ', end='')
	print(lista2[i], end='')
print()


from collections import defaultdict
n = int(input())
a = [int(i) for i in input().split()]
l1 = []
l2 = []
da = defaultdict(int)
db = defaultdict(int)
check = 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:
		check = False
if check:
	print('YES')
	print(len(l1))
	print(*sorted(l1))
	print(len(l2))
	l2 = sorted(l2)
	l2 = l2[::-1]
	print(*l2)
else:
	print('NO')


def calc(n, a):
	dic = {}
	orig = []
	storedextra = []
	for i in a:
		if i not in dic:
			orig.append(i)
			dic[i] = 1
		else:
			storedextra.append(i)
	flag = True
	storedextra.sort()
	orig.sort(reverse=True)
	for i in range(1, len(storedextra)):
		if storedextra[i] == storedextra[i - 1]:
			flag = False
			break
	for j in range(1, len(orig)):
		if orig[j] == orig[j - 1]:
			flag = False
			break
	if flag:
		print('YES')
		print(len(storedextra))
		print(*storedextra)
		print(len(orig))
		print(*orig)
	else:
		print('NO')
n = int(input())
a = list(map(int, input().split()))
calc(n, a)


import collections
n = int(input())
a = [int(x) for x in input().split()[:n]]
d = list()
f = 0
a.sort(reverse=True)
counter = collections.Counter(a)
for i in range(max(a) + 1):
	if counter[i] > 2:
		print('NO')
		f = 1
		break
	elif counter[i] == 2:
		d.append(i)
d.sort()
if f != 1:
	print('YES')
	print(len(d))
	d = [str(x) for x in d]
	print(' '.join(d))
	a = list(dict.fromkeys(a))
	a = [str(x) for x in a]
	print(len(a))
	print(' '.join(a))


def main():
	n = int(input())
	arr = list(map(int, input().split()))
	dic = {}
	for i in range(n):
		if arr[i] not in dic:
			dic[arr[i]] = 1
		else:
			dic[arr[i]] += 1
	inc = []
	dec = []
	sol = True
	for (k, v) in dic.items():
		if v > 2:
			sol = False
			break
		elif v == 2:
			inc.append(k)
			dec.append(k)
		else:
			dec.append(k)
	if sol:
		print('YES')
		print(len(inc))
		inc.sort()
		for i in range(len(inc)):
			print(inc[i], end=' ')
		print()
		print(len(dec))
		dec.sort(reverse=True)
		for i in range(len(dec)):
			print(dec[i], end=' ')
	else:
		print('NO')
main()


I = lambda : list(map(int, input().split()))
(n,) = I()
l = I()
ar = [0] * 200001
fl = 1
for i in l:
	ar[i] += 1
	if ar[i] > 2:
		print('NO')
		fl = 0
		break
if fl:
	print('YES')
	inc = []
	dec = []
	for i in range(len(ar)):
		if ar[i]:
			if ar[i] == 1:
				inc.append(i)
			else:
				inc.append(i)
				dec.append(i)
	print(len(inc))
	print(*inc)
	print(len(dec))
	print(*dec[::-1])


from collections import defaultdict
d = defaultdict(int)

def check_existence(array):
	for v in array:
		d[v] += 1
	if max(d.values()) > 2:
		return 0
	else:
		return 1

def fun(array, n):
	strictly_incr = []
	strictly_decr = []
	check = check_existence(array)
	if check == 0:
		print('NO')
	else:
		array.sort()
		for i in range(n):
			if len(strictly_incr) == 0 or strictly_incr[-1] != array[i]:
				strictly_incr.append(array[i])
			else:
				strictly_decr.append(array[i])
	if check == 1:
		print('YES')
		if len(strictly_incr) == 0:
			print(0)
			print(' ')
		else:
			print(len(strictly_incr))
			print(*strictly_incr)
		if len(strictly_decr) == 0:
			print(0)
			print(' ')
		else:
			print(len(strictly_decr))
			print(*strictly_decr[::-1])
n = int(input())
array = list(map(int, input().split()))
fun(array, n)


n = int(input())
mas = [int(i) for i in input().split()]
mas = sorted(mas)
m1 = set()
m2 = []
for i in range(len(mas)):
	if mas[i] not in m1:
		m1.add(mas[i])
	elif mas[i] not in m2:
		m2.append(mas[i])
if len(m1) + len(m2) == n:
	print('YES')
	print(len(m1))
	print(*m1)
	print(len(m2))
	print(*m2[::-1])
else:
	print('NO')


def main():
	_ = int(input())
	numbers = sorted(map(int, input().split()))
	(xs, ys) = ([], [])
	for number in numbers:
		if not xs or xs[-1] != number:
			xs.append(number)
		elif not ys or ys[-1] != number:
			ys.append(number)
		else:
			print('NO')
			return
	print('YES')
	print(len(xs))
	print(*xs)
	print(len(ys))
	print(*ys[::-1])
main()


from typing import List, Tuple
import sys
DEBUG = len(sys.argv) > 1 and sys.argv[1] == '-d'

def LOG(*argv):
	if DEBUG:
		print(*argv, file=sys.stderr)

def CHECK(cond, err_msg=''):
	if DEBUG:
		assert cond, err_msg

def CHECK_EQ(a, b, err_msg=''):
	CHECK(a == b, err_msg='{} v.s. {} {}'.format(a, b, err_msg))

def readval(typ=int):
	return typ(input())

def readvals(typ=int):
	return map(typ, input().split())

def solve(arr: List[int]) -> Tuple[List[int], List[int]]:
	from collections import Counter
	ctr = Counter(arr)
	if ctr.most_common(1)[0][1] > 2:
		return (None, None)
	(inc_arr, dec_arr) = ([], [])
	for (v, cnt) in ctr.items():
		inc_arr.append(v)
		if cnt == 2:
			dec_arr.append(v)
	return (sorted(inc_arr), sorted(dec_arr, reverse=True))
_ = readval()
arr = readvals()
(inc_arr, dec_arr) = solve(arr)
if inc_arr is None:
	print('NO')
else:
	print('YES')
	print(len(inc_arr))
	print(*inc_arr, sep=' ')
	print(len(dec_arr))
	print(*dec_arr, sep=' ')


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')
		exit(0)
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)


n = int(input())
arr = [int(x) for x in input().split()]
arr.sort()
inc = []
dec = []
count = 0
last = -1
for x in arr:
	if last == x:
		count += 1
	else:
		count = 0
	if count == 0:
		inc.append(x)
	elif count == 1:
		dec.append(x)
	else:
		print('NO')
		exit()
	last = x
print('YES')
print(len(inc))
print(' '.join(map(str, inc)))
print(len(dec))
print(' '.join(map(str, dec[::-1])))


import sys, bisect, string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby
rep = range
R = range

def Golf():
	(n, *t) = map(int, open(0).read().split())

def I():
	return int(input())

def S_():
	return input()

def IS():
	return input().split()

def LS():
	return [i for i in input().split()]

def MI():
	return map(int, input().split())

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def RA():
	return map(int, open(0).read().split())

def RLI(n=8, a=1, b=10):
	return [random.randint(a, b) for i in range(n)]

def RI(a=1, b=10):
	return random.randint(a, b)

def Rtest(T):
	(case, err) = (0, 0)
	for i in range(T):
		inp = INP()
		(a1, ls) = naive(*inp)
		a2 = solve(*inp)
		if a1 != a2:
			print((a1, a2), inp)
			err += 1
		case += 1
	print('Tested', case, 'case with', err, 'errors')

def GI(V, E, ls=None, Directed=False, index=1):
	org_inp = []
	g = [[] for i in range(V)]
	FromStdin = True if ls == None else False
	for i in range(E):
		if FromStdin:
			inp = LI()
			org_inp.append(inp)
		else:
			inp = ls[i]
		if len(inp) == 2:
			(a, b) = inp
			c = 1
		else:
			(a, b, c) = inp
		if index == 1:
			a -= 1
			b -= 1
		aa = (a, c)
		bb = (b, c)
		g[a].append(bb)
		if not Directed:
			g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}, boundary=1):
	mp = [boundary] * (w + 2)
	found = {}
	for i in R(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def accum(ls):
	rt = [0]
	for i in ls:
		rt += [rt[-1] + i]
	return rt

def bit_combination(n, base=2):
	rt = []
	for tb in R(base ** n):
		s = [tb // base ** bt % base for bt in R(n)]
		rt += [s]
	return rt

def gcd(x, y):
	if y == 0:
		return x
	if x % y == 0:
		return y
	while x % y != 0:
		(x, y) = (y, x % y)
	return y

def YN(x):
	print(['NO', 'YES'][x])

def Yn(x):
	print(['No', 'Yes'][x])

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
mo = 10 ** 9 + 7
inf = float('inf')
FourNb = [(-1, 0), (1, 0), (0, 1), (0, -1)]
EightNb = [(-1, 0), (1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
compas = dict(zip('WENS', FourNb))
cursol = dict(zip('LRUD', FourNb))
l_alp = string.ascii_lowercase
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
input = lambda : sys.stdin.readline().rstrip()
show_flg = False
show_flg = True
ans = 0
ans = []
n = I()
x = []
y = []
for (i, j) in Counter(LI()).items():
	x += (i,)
	if j > 2:
		print('NO')
		exit()
	elif j > 1:
		y += (i,)
print('YES')
print(len(x))
print(*sorted(x))
print(len(y))
print(*sorted(y)[::-1])


import collections
a = int(input())
z = list(map(int, input().split()))
if len(z) == len(set(z)):
	print('YES')
	print(len(z))
	print(' '.join(map(str, sorted(z))))
	print(0)
	print(' ')
else:
	even = []
	odd = []
	z = sorted(z)
	for i in range(len(z)):
		if i % 2 == 0:
			even.append(z[i])
		else:
			odd.append(z[i])
	if len(odd) != len(set(odd)) or len(even) != len(set(even)):
		print('NO')
		exit()
	even = sorted(even)
	odd = sorted(odd)
	odd = odd[::-1]
	print('YES')
	print(len(even))
	print(' '.join(map(str, even)))
	print(len(odd))
	print(' '.join(map(str, odd)))


n = int(input())
arr = list(map(int, input().split()))
from collections import Counter
count = Counter(arr)
if max(count.values()) > 2:
	print('NO')
else:
	print('YES')
	if len(arr) == 1:
		print(0)
		print()
		print(1)
		print(arr[0])
	elif len(arr) == 2:
		print(1)
		print(arr[0])
		print(1)
		print(arr[1])
	else:
		ans1 = []
		ans2 = []
		for key in count:
			if count[key] >= 1:
				ans1.append(key)
			if count[key] == 2:
				ans2.append(key)
		ans1.sort()
		ans2.sort(reverse=True)
		print(len(ans1))
		for val in ans1:
			print(val, end=' ')
		print()
		print(len(ans2))
		for val in ans2:
			print(val, end=' ')


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

def m():
	d = {}
	for i in a:
		if d.get(i, 0) == 0:
			d[i] = 1
		else:
			d[i] += 1
	for j in d.values():
		if j > 2:
			print('NO')
			return
	incres = []
	decres = []
	tmp = list(d.items())
	tmp.sort(key=lambda x: x[0])
	item = []
	for i in range(len(tmp)):
		(k, v) = tmp[i]
		item.append([k, v])
	for i in range(len(item)):
		(k, v) = item[i]
		incres.append(k)
		item[i][1] -= 1
	for j in reversed(range(len(item))):
		(k, v) = item[j]
		if v == 0:
			continue
		decres.append(k)

	def show_ans(array):
		if len(array) == 0:
			print('0')
			print('')
		else:
			print(len(array))
			for x in array:
				print(x, end='')
				print(' ', end='')
			print('')
	print('YES')
	show_ans(incres)
	show_ans(decres)
m()


n = int(input())
arr = list(map(int, input().split()))
d = {}
for i in arr:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
for (key, value) in d.items():
	if value > 2:
		print('NO')
		exit()
arr = sorted(arr)
ans1 = []
ans2 = []
for i in range(0, len(arr), 2):
	ans1.append(arr[i])
	if i + 1 < len(arr):
		ans2.append(arr[i + 1])
ans2.sort(reverse=True)
print('YES')
print(len(ans1))
for i in ans1:
	print(i, end=' ')
print()
print(len(ans2))
for i in ans2:
	print(i, end=' ')
print()


def f(n, a):
	x = []
	y = []
	v = []
	s = True
	for i in a:
		if len(x) == 0 or x[-1] != i:
			x.append(i)
		elif len(y) == 0 or y[-1] != i:
			y.append(i)
		else:
			s = False
	y.reverse()
	if s:
		print('YES')
		print(len(x))
		print(' '.join([str(i) for i in x]))
		print(len(y))
		print(' '.join([str(i) for i in y]))
	else:
		print('NO')
n = input()
a = input().strip().split()
a = sorted(list(map(int, a)))
f(n, a)


from collections import Counter
n = int(input())
arr = list(map(int, input().split()))
cnts = Counter(arr)
if any([x > 2 for x in cnts.values()]):
	print('NO')
else:
	increasing = sorted(cnts.keys())
	decreasing = sorted([i for (i, v) in cnts.items() if v == 2], reverse=True)
	print('YES')
	print(len(increasing))
	print(*increasing)
	print(len(decreasing))
	print(*decreasing)


n = int(input())
a = list(map(int, input().strip().split(' ')))
a.sort()
b = list(set(a))
b.sort()
res = []
fg = [0 for _ in range(222222)]
p = 'Yes'
for i in a:
	fg[i] += 1
	if fg[i] > 2:
		p = 'No'
for i in a:
	if fg[i] == 2:
		res.append(i)
res = list(set(res))
res.sort(reverse=True)
if p == 'No':
	print(p)
else:
	print(p)
	print(len(b))
	if len(b) > 0:
		for j in b:
			print(j, end=' ')
	elif len(b) == 0:
		print(' ')
	io = len(res)
	print('\n' + str(len(res)))
	if len(res) > 0:
		for k in res:
			print(k, end=' ')
	elif len(res) == 0:
		print(' ')


n = int(input())
s = list(map(int, input().split()))
s.sort()
d = s[::2]
f = s[1::2]
if len(set(d)) + len(set(f)) < len(s):
	print('NO')
else:
	print('YES')
	print(len(d))
	print(*d)
	print(len(f))
	print(*f[::-1])


n = int(input())
a = [*map(int, input().split(' '))]
h = {}
for x in a:
	if h.get(x) != None:
		h[x] = h[x] + 1
	else:
		h[x] = 1
	if h[x] > 2:
		print('NO')
		exit(0)
print('YES')
g = []
l = []
a = sorted(a)
for x in a:
	if len(g) == 0:
		g.append(x)
		continue
	if x != g[-1]:
		g.append(x)
	else:
		l.append(x)
l = sorted(l, reverse=True)
print(len(g))
print(*g)
print(len(l))
print(*l)


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)
	elif 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()


def main():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	b = list()
	i = 1
	while i < len(a):
		if a[i] == a[i - 1]:
			b.append(a.pop(i))
		else:
			i += 1
	for i in range(1, len(b)):
		if b[i] == b[i - 1]:
			print('NO')
			return
	b.reverse()
	print('YES')
	print(len(a))
	print(*a)
	print(len(b))
	print(*b)
main()


n = int(input())
l = list(map(int, input().split()))
if n == 1:
	print('YES')
	print(1)
	print(*l)
	print(0)
	print()
elif n == 2:
	print('YES')
	print(1)
	print(l[0])
	print(1)
	print(l[1])
elif len(set(l)) == 1:
	print('NO')
else:
	inc = []
	dec = []
	l.sort()
	for i in range(n - 1):
		if l[i] < l[i + 1]:
			inc.append(l[i])
		else:
			dec.append(l[i])
	if inc[len(inc) - 1] != l[n - 1]:
		inc.append(l[n - 1])
	else:
		dec.append(l[n - 1])
	inc = list(set(inc))
	dec = list(set(dec))
	if len(inc) + len(dec) != n:
		print('NO')
	else:
		print('YES')
		inc.sort()
		dec.sort(reverse=True)
		print(len(inc))
		print(*inc)
		print(len(dec))
		print(*dec)


n = int(input())
L = list(map(int, input().split()))
L.sort()
d = set(L)
K = []
P = []
count = 0
if len(L) == len(d):
	print('YES')
	print(len(L))
	print(*L)
	print(0)
	print(' ')
else:
	flag = 0
	for i in range(n - 1):
		if L[i] == L[i + 1]:
			count = count + 1
			if count > 1:
				flag = 1
				print('NO')
				break
			else:
				K.insert(0, L[i])
		else:
			P.append(L[i])
			count = 0
	if flag == 0:
		P.append(L[-1])
		print('YES')
		print(len(P))
		print(*P)
		print(len(K))
		print(*K)


import copy
n = int(input())
a = list(map(int, input().split()))
a.sort()
z = []
x = []
y = 0
w = 0
for i in range(0, n - 1):
	if a[i] == a[i + 1]:
		y += 1
		x.append(a[i])
	elif y >= 2:
		w = 1
		break
	else:
		z.append(a[i])
		y = 0
z.append(a[n - 1])
if w == 1:
	print('NO')
else:
	print('YES')
	print(len(x))
	for i in range(0, len(x)):
		print(x[i], end=' ')
	print()
	print(len(z))
	z = z[::-1]
	for i in range(0, len(z)):
		print(z[i], end=' ')


n = int(input())
l = list(map(int, input().split()))
l1 = [-1]
l2 = [-1]
l.sort()
i = 0
f = 0
while i < n:
	if l[i] != l1[-1]:
		l1.append(l[i])
	elif l[i] == l2[-1]:
		f = 1
		break
	else:
		l2.append(l[i])
	i += 1
if f == 1:
	print('NO')
else:
	print('YES')
	print(len(l1) - 1)
	l1.remove(l1[0])
	l2.remove(l2[0])
	print(*l1)
	print(len(l2))
	l2.sort(reverse=True)
	print(*l2)


_ = int(input())
SEQUENCE = sorted([int(item) for item in input().split()])
INCREASING = SEQUENCE[0::2]
DECREASING = SEQUENCE[1::2]
if len(set(INCREASING)) < len(INCREASING) or len(set(DECREASING)) < len(DECREASING):
	print('NO')
else:
	print('YES')
	print(len(INCREASING))
	print(' '.join([str(x) for x in INCREASING]))
	print(len(DECREASING))
	print(' '.join(reversed([str(x) for x in DECREASING])))


import collections

def SI():
	return input()

def II():
	return int(SI())

def STI():
	return SI().split()

def ITI():
	return map(int, STI())

def SLI():
	return list(SI())

def ILI():
	return list(ITI())
n = II()
a = ILI()
ac = collections.Counter(a)
s = []
d = []
for (k, v) in ac.items():
	if v > 2:
		print('NO')
		quit()
	s.append(k) if v < 2 else d.append(k)
(ls, ld) = (len(s), len(d))
il = sorted(s[:ls // 2] + d)
dl = sorted(s[ls // 2:] + d, reverse=True)
print('YES')
print(len(il))
print(' '.join(map(str, il)))
print(len(dl))
print(' '.join(map(str, dl)))


import sys
input = sys.stdin.readline
N = int(input())
a = sorted(map(int, input().split()))
inc = []
dec = []
dic = {}
for i in a:
	dic[i] = dic.get(i, 0) + 1
	inc.append(i) if dic[i] > 1 else dec.append(i)
	if dic[i] > 2:
		print('NO')
		exit()
print('YES')
print(len(inc))
print(*inc)
print(len(dec))
print(*reversed(dec))


from sys import stdin, exit
stdin.readline()
numbers = sorted(map(int, stdin.readline().rstrip().split(' ')))
increasing = [numbers[0]]
duplicates = []
for number in numbers[1:]:
	if number == increasing[-1]:
		if duplicates and number == duplicates[-1]:
			print('NO')
			exit(0)
		else:
			duplicates.append(number)
	else:
		increasing.append(number)
print('YES')
print(len(increasing))
print(' '.join(map(str, increasing)))
print(len(duplicates))
print(' '.join(map(str, duplicates[::-1])))


n = int(input())
l = list(map(int, input().split()))
l.sort()
c = [0 for i in range(n)]
maxu = l[0]
increase = []
increase.append(maxu)
c[0] = 1
for i in range(1, n):
	if l[i] > maxu:
		maxu = l[i]
		c[i] = 1
		increase.append(maxu)
decrease = []
minu = -1
for i in range(n - 1, -1, -1):
	if minu == -1 and c[i] != 1:
		minu = l[i]
		c[i] = 1
		decrease.append(minu)
	elif l[i] < minu and c[i] != 1:
		minu = l[i]
		c[i] = 1
		decrease.append(minu)
if sum(c) != n:
	print('NO')
else:
	print('YES')
	print(len(increase))
	if len(increase) == 0:
		print()
	else:
		for i in increase:
			print(i, end=' ')
		print()
	print(len(decrease))
	if len(decrease) == 0:
		print()
	else:
		for i in decrease:
			print(i, end=' ')


n = int(input())
arr = [int(x) for x in input().split()]
dic1 = {}
dic2 = {}
temp = 0
for i in arr:
	if i not in dic1:
		dic1[i] = 1
	elif i not in dic2:
		dic2[i] = 1
	else:
		print('NO')
		temp = 1
		break
if temp == 0:
	print('YES')
	print(len(dic1))
	if len(dic2) == 0:
		print(' ', end=' ')
	dic1 = sorted(dic1)
	for i in dic1:
		print(i, end=' ')
	dic2 = sorted(dic2)
	print(' ')
	print(len(dic2))
	if len(dic2) == 0:
		print(' ')
	dic2 = dic2[::-1]
	for i in dic2:
		print(i, end=' ')


a = int(input())
s = [int(x) for x in input().split()]
s.sort()
d = {}
r = 0
l = 0
key = True
for i in range(a):
	d[s[i]] = 0
for i in s:
	if d[i] == 2:
		print('NO')
		key = False
		break
	elif d[i] == 0:
		l += 1
		d[i] += 1
	else:
		r += 1
		d[i] += 1
if key:
	print('YES')
	print(r)
	for i in d:
		if d[i] == 2:
			d[i] -= 1
			print(i, end=' ')
	print()
	print(l)
	s.clear()
	for i in d:
		if d[i] == 1:
			s.append(str(i))
	print(' '.join(s[::-1]))


import collections
t = int(input())
l = list(map(int, input().split()))
counter = collections.Counter(l)
cv = counter.values()
ck = counter.keys()
fl = []
ans = []
for (i, j) in zip(ck, cv):
	if j == 2:
		fl.append(i)
sl = set(l)
for i in cv:
	if i >= 3:
		ans.append('NO')
		break
if 'NO' in ans:
	print('NO')
else:
	print('YES')
	print(len(fl))
	print(*sorted(fl))
	print(len(sl))
	print(*sorted(sl, reverse=True))


from collections import defaultdict
MyDict = defaultdict(int)
input()
for i in list(map(int, input().split())):
	MyDict[i] += 1
if list(MyDict.values()).count(1) + list(MyDict.values()).count(2) != len(MyDict):
	print('NO')
	exit()
(inc, dec) = ([], [])
for i in MyDict.keys():
	inc.append(i)
	if MyDict[i] == 2:
		dec.append(i)
print('YES\n' + str(len(inc)))
print(*sorted(inc))
print(str(len(dec)))
print(*sorted(dec, reverse=True))


from collections import *
n = int(input())
l = list(map(int, input().split()))
m = []
k = []
c = Counter(l)
if max(c.values()) > 2:
	print('NO')
	exit(0)
for i in c.items():
	m.append(i[0])
	if i[1] == 2:
		k.append(i[0])
print('YES')
m.sort()
k.sort(reverse=True)
print(len(m))
print(*m)
print(len(k))
print(*k)


n = int(input())
arr = [int(x) for x in input().split()]
b = False
arr.sort()
for i in range(0, len(arr) - 2):
	if arr[i] == arr[i + 1] and arr[i + 1] == arr[i + 2]:
		b = True
if b:
	print('NO')
else:
	print('YES')
	i = 0
	arr2 = []
	while i < len(arr) - 1:
		if arr[i] == arr[i + 1]:
			arr2.append(arr[i])
			arr.pop(i)
			i = i - 1
		i = i + 1
	arr2.reverse()
	print(len(arr))
	for ele in arr:
		print(ele, end=' ')
	print()
	print(len(arr2))
	for ele in arr2:
		print(ele, end=' ')


n = int(input())
ans = list(map(int, input().split()))
(s, s2) = (set(), set())
for i in ans:
	if i in s:
		s2.add(i)
	else:
		s.add(i)
if len(s) + len(s2) == n:
	print('YES')
	print(len(s))
	print(*sorted(s))
	print(len(s2))
	print(*sorted(list(s2), reverse=True))
else:
	print('NO')


import collections
input()
data = sorted(list(map(int, input().split())))
x = collections.Counter(data)
first = []
second = []
no = False
for i in x:
	if x[i] > 2:
		print('NO')
		no = True
		break
	elif x[i] == 2:
		first.append(i)
		second.append(i)
	else:
		first.append(i)
first = sorted(first)
second = sorted(second)[::-1]
(first_str, second_str) = ['', '']
for i in first:
	first_str += str(i) + ' '
for i in second:
	second_str += str(i) + ' '
if not no:
	print('YES')
	print(len(first))
	print(first_str)
	print(len(second))
	print(second_str)


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()


import math
import sys

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))
MAX = 2 * 10 ** 5 + 7
n = ii()
d = sorted(li())
d.append(MAX - 1)
used = [0] * MAX
f = []
s = []
for i in range(n):
	if used[d[i]] > 1:
		exit(print('NO'))
	used[d[i]] += 1
	if d[i] == d[i + 1]:
		f.append(d[i])
	else:
		s.append(d[i])
print('YES')
print(len(f))
print(' '.join([str(x) for x in f]))
print(len(s))
print(' '.join([str(x) for x in reversed(s)]))


def TwoShuffledSequences(n, seq):
	cntArr = [0] * 200001
	for s in seq:
		cntArr[s] += 1
		if cntArr[s] > 2:
			print('NO')
			return
	cntA = 0
	a = ''
	i = 0
	while i <= 200000:
		if cntArr[i] == 2:
			a += str(i)
			cntA += 1
			a += ' '
		i += 1
	b = ''
	i = 200000
	while i >= 0:
		if cntArr[i] != 0:
			b += str(i)
			b += ' '
		i -= 1
	print('YES')
	print(cntA)
	print(a.rstrip())
	print(n - cntA)
	print(b.rstrip())
n = int(input())
seq = [int(x) for x in input().split()]
TwoShuffledSequences(n, seq)


R = lambda : map(int, input().split())
n = int(input())
L = sorted(R())
f = [0] * (max(L) + 1)
flag = 0
for i in L:
	f[i] += 1
	if f[i] == 3:
		flag = 1
		break
if flag:
	print('NO')
else:
	print('YES')
	(a1, a2) = ([], [])
	for i in range(len(f)):
		if f[i] == 1:
			a1.append(i)
		elif f[i] == 2:
			a1.append(i)
			a2.append(i)
	print(len(a1))
	print(*a1)
	print(len(a2))
	a2 = a2[::-1]
	print(*a2)


n = int(input())
a = list(map(int, input().split()))
d = {}
n1 = []
n2 = []
for i in a:
	if i not in d:
		d[i] = 1
		n1.append(i)
	elif d[i] == 2:
		print('NO')
		exit()
	else:
		n2.append(i)
		d[i] += 1
print('YES')
print(len(n2))
n2.sort()
print(*n2)
print(len(n1))
n1.sort(reverse=1)
print(*n1)


n = int(input())
a = [int(ai) for ai in input().split()] + [0]
(inc, dec) = (-1, 10 ** 6)
marker = [0] * n
for i in range(n):
	if inc < a[i] and a[i] < dec:
		if a[i] < a[i + 1]:
			inc = a[i]
		else:
			dec = a[i]
			marker[i] = 1
	elif inc < a[i]:
		inc = a[i]
	elif dec > a[i]:
		dec = a[i]
		marker[i] = 1
	else:
		print('NO')
		break
else:
	print('YES')
	print(*marker)


def main():
	n = int(input())
	v = input().split()
	seta = set()
	k = 0
	m = 0
	a = []
	for i in range(n):
		seta.add(int(v[i]))
		k = len(seta)
		if m == k:
			a.append(int(v[i]))
		m = len(seta)
	ans1 = []
	for i in seta:
		ans1.append(i)
	ans1.sort()
	ans1.reverse()
	if len(set(a)) != len(a):
		print('NO')
	else:
		print('YES')
		print(len(a))
		a.sort()
		print(' '.join([str(x) for x in a]))
		print(len(ans1))
		print(' '.join([str(x) for x in ans1]))
main()


n = int(input())
a = list(map(int, input().split()))
a.sort()
b = []
for i in range(len(a) - 1):
	if a[i] == a[i + 1]:
		b.append(a[i])
		if b[len(b) - 1] == b[len(b) - 2] and len(b) > 1:
			print('NO')
			exit()
print('YES')
a = list(set(a))
a.sort()
b.reverse()
print(len(a))
for i in a:
	print(i, end=' ')
print()
print(len(b))
for i in b:
	print(i, end=' ')
print()


from collections import defaultdict
n = int(input())
A = [int(i) for i in input().split()]
mx = 0
dd = defaultdict(int)
for i in range(n):
	dd[A[i]] += 1
	mx = max(mx, dd[A[i]])
if mx > 2:
	print('NO')
else:
	inc = []
	dec = []
	for i in dd:
		if dd[i] == 2:
			dec.append(i)
		inc.append(i)
	print('YES')
	print(len(inc))
	print(*sorted(inc))
	print(len(dec))
	print(*sorted(dec, reverse=True))


a = int(input())
A = list(map(int, input().split()))
B = set()
C = set()
i = 0
k = True
while i < a and k == True:
	if A[i] not in B:
		B.add(A[i])
	elif A[i] not in C:
		C.add(A[i])
	else:
		k = False
	i += 1
if k == True:
	print('YES')
	B = list(B)
	B.sort()
	C = list(C)
	C.sort()
	B.reverse()
	print(len(C))
	print(*C)
	print(len(B))
	print(*B)
else:
	print('NO')


from collections import *
(n, a) = (int(input()), list(map(int, input().split())))
(d1, d2, mem) = ([], [], Counter(a))
for (i, j) in mem.items():
	if j > 2:
		exit(print('NO'))
	else:
		d1.append(i)
		if j == 2:
			d2.append(i)
print('YES')
print(len(d1))
print(*sorted(d1))
print(len(d2))
print(*sorted(d2)[::-1])


n = int(input())
a = list(map(int, input().split()))
count = [0] * (max(a) + 1)
maxCount = 0
for el in a:
	count[el] += 1
	maxCount = max(maxCount, count[el])
if maxCount > 2:
	print('NO')
else:
	print('YES')
	seq = []
	for i in range(len(count)):
		if count[i]:
			seq.append(i)
			count[i] -= 1
	print(len(seq))
	for el in seq:
		print(el, end=' ')
	print()
	seq = []
	for i in range(len(count) - 1, -1, -1):
		if count[i]:
			seq.append(i)
	print(len(seq))
	for el in seq:
		print(el, end=' ')
	print()


from collections import Counter

def main():
	n = int(input())
	a = list(map(int, input().split()))
	ca = Counter(a)
	if any([v > 2 for v in ca.values()]):
		print('NO')
	else:
		print('YES')
		a.sort()
		dec = []
		inc = []
		for (k, v) in ca.items():
			if v == 2:
				dec.append(k)
				inc.append(k)
			else:
				inc.append(k)
		inc.sort()
		dec.sort(reverse=True)
		print(len(inc))
		print(str(inc)[1:-1].replace(',', ''))
		print(len(dec))
		print(str(dec)[1:-1].replace(',', ''))
main()


n = int(input())
r = [int(item) for item in input().split()]
m = {key: 0 for key in r}
for x in r:
	m[x] += 1
for x in m:
	if m[x] > 2:
		print('NO')
		break
else:
	(x, y) = ([], [])
	for e in m:
		if m[e] == 2:
			x.append(e)
			y.append(e)
		else:
			x.append(e)
	x.sort()
	y.sort(reverse=True)
	assert len(x) + len(y) == len(r)
	print('YES')
	print(len(x))
	print(*x)
	print(len(y))
	print(*y)


n = int(input())
l = list(map(int, input().split(' ')))
c = [0 for i in range(2 * 10 ** 5 + 1)]
a = []
b = []
for i in l:
	c[i] += 1
if max(c) > 2:
	print('NO')
else:
	print('YES')
	for i in range(len(c)):
		if c[i] == 2:
			a.append(i)
			b.append(i)
		if c[i] == 1:
			b.append(i)
	a.sort()
	b.sort()
	print(len(a))
	if len(a) != 0:
		for i in range(len(a) - 1):
			print(a[i], end=' ')
		print(a[len(a) - 1])
	else:
		print(' ')
	print(len(b))
	if len(b) != 0:
		for i in range(len(b) - 1, 0, -1):
			print(b[i], end=' ')
		print(b[0])
	else:
		print(' ')


a = int(input())
x = [int(i) for i in input().split()]
di = {i: 0 for i in range(200001)}
d = set(x)
d = sorted(d, reverse=True)
hasil = []
for i in range(len(x)):
	if di[x[i]] > 1:
		print('NO')
		exit(0)
	elif di[x[i]] == 1:
		hasil.append(x[i])
		di[x[i]] += 1
	else:
		di[x[i]] += 1
print('YES')
hasil.sort()
print(len(hasil))
if len(hasil) == 0:
	print()
for i in hasil:
	if i == hasil[-1]:
		print(i)
	else:
		print(i, end=' ')
print(len(d))
for i in d:
	if i == d[-1]:
		print(i)
	else:
		print(i, end=' ')


from collections import *
n = int(input())
l = list(map(int, input().split()))
fre = Counter(l)
flag = True
if n == 1:
	print('YES')
	print(1)
	print(l[0])
	print(0)
	print()
	exit()
for i in l:
	if fre[i] > 2:
		flag = False
		break
if not flag:
	print('NO')
else:
	print('YES')
	s = set(l)
	if len(s) == len(l):
		print(1)
		l.sort(reverse=True)
		print(l[0])
		print(n - 1)
		for i in range(1, n):
			print(l[i], end=' ')
	else:
		even = set()
		odd = set()
		for i in l:
			if i in even:
				odd.add(i)
			else:
				even.add(i)
		even = sorted(even)
		odd = sorted(odd, reverse=True)
		print(len(even))
		for i in even:
			print(i, end=' ')
		print(len(odd))
		for i in odd:
			print(i, end=' ')


n = int(input())
arr = [int(i) for i in input().split()]
arr.sort()
l1 = []
n1 = 0
l2 = []
n2 = 0
i = 0
while i < n:
	if i <= n - 3 and arr[i] == arr[i + 1] == arr[i + 2]:
		print('NO')
		exit()
	elif i <= n - 2 and arr[i] == arr[i + 1]:
		l1.append(arr[i])
		l2.append(arr[i])
		n1 += 1
		n2 += 1
		i = i + 2
	else:
		l1.append(arr[i])
		n1 += 1
		i += 1
print('YES')
l2.sort(reverse=True)
print(n1)
print(*l1)
print(n2)
print(*l2)


n = int(input())
a = list(map(int, input().split()))
b = dict()
flag = True
for i in a:
	if i in b:
		b[i] += 1
		if b[i] == 3:
			flag = False
	else:
		b[i] = 1
up = []
down = []
if flag:
	for i in range(max(b) + 1):
		if i in b:
			if b[i] == 2:
				up.append(i)
				down.append(i)
			else:
				up.append(i)
	print('YES')
	print(len(up))
	print(*up)
	down.reverse()
	print(len(down))
	print(*down)
else:
	print('NO')


from collections import Counter as c
n = int(input())
a = list(map(int, input().split()))
cnt = c(a)
cnt = sorted(cnt.items(), key=lambda x: x[1], reverse=True)
if cnt[0][1] > 2:
	print('NO')
	exit()
print('YES')
ans = []
cnt = sorted(cnt, key=lambda x: x[0])
res = []
for i in cnt:
	if i[1] == 2:
		ans.append(i[0])
		res.append(i[0])
	else:
		res.append(i[0])
print(len(ans))
print(*ans)
res.sort(reverse=True)
print(len(res))
print(*res)


from collections import Counter
n = int(input())
numl = list(map(int, input().split()))
(decrese, increse) = ([], [])
c = Counter(numl)
if c.most_common(1)[0][1] > 2:
	print('NO')
else:
	for cnt in c.items():
		if cnt[1] == 2:
			decrese.append(int(cnt[0]))
	for i in c.keys():
		increse.append(int(i))
	increse.sort()
	decrese.sort(reverse=True)
	print('YES')
	print(len(increse))
	print(' '.join(map(str, increse)))
	print(len(decrese))
	print(' '.join(map(str, decrese)))


n = int(input())
ai = list(map(int, input().split()))
counter = {}
for i in ai:
	if i not in counter:
		counter[i] = 1
	else:
		counter[i] += 1
inc = []
res = True
for (k, v) in counter.items():
	if v > 2:
		print('NO')
		res = False
		break
	if v == 2:
		inc.append(k)
		counter[k] -= 1
else:
	print('YES')
inc.sort()
dec = []
for (k, v) in counter.items():
	dec.append(k)
dec.sort(reverse=True)
if res == True:
	print(len(inc))
	print(*inc)
	print(len(dec))
	print(*dec)


n = int(input())
z = list(map(int, input().split()))
z.sort()
a = set()
b = set()
c = 0
ans = 'YES'
for x in z:
	c += 1
	if x not in a:
		a.add(x)
	elif x not in b:
		b.add(x)
	else:
		ans = 'NO'
		print('NO')
		break
if c == n and ans == 'YES':
	print('YES')
	print(len(a))
	print(*sorted(a))
	print(len(b))
	print(*sorted(b, reverse=True))


import sys
import math
import itertools
import collections

def getdict(n):
	d = {}
	if type(n) is list or type(n) is str:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return ' '.join(map(str, arr))

def revn(n):
	return int(str(n)[::-1])

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base=3):
	newnumber = ''
	while number > 0:
		newnumber = str(number % base) + newnumber
		number //= base
	return newnumber
n = ii()
a = li()
c = [0] * (2 * 10 ** 5 + 1)
for i in range(n):
	c[a[i]] += 1
(pos, neg) = ([], [])
for i in range(2 * 10 ** 5 + 1):
	if c[i] == 1:
		pos.append(i)
	elif c[i] == 2:
		pos.append(i)
		neg.append(i)
	elif c[i] > 2:
		exit(print('NO'))
print('YES')
print(len(pos))
print(wr(pos))
print(len(neg))
print(wr(reversed(neg)))


flag = True
input()
dat = input().split()
data = [int(i) for i in dat]
data.sort()
prev = -1
prim = []
sec = ['']
for num in data:
	if num == prev:
		sec.append(num)
		if sec[-1] == sec[-2]:
			flag = False
			break
	else:
		prim.append(num)
		prev = num
if not flag:
	print('NO')
else:
	print('YES')
	sec.reverse()
	print(len(prim))
	print(' '.join([str(p) for p in prim]))
	print(len(sec) - 1)
	print(' '.join([str(p) for p in sec]))


import bisect
import os
import gc
import sys
from io import BytesIO, IOBase
from collections import Counter
from collections import deque
import heapq
import math
import statistics

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def main():
	n = iin()
	a = ain()
	a.sort()
	na = deque([a[0]])
	nd = deque([])
	for i in range(1, n):
		if na[-1] < a[i]:
			na.append(a[i])
		else:
			nd.append(a[i])
	if len(set(nd)) == len(nd):
		print('YES')
		print(len(na))
		print(*na)
		print(len(nd))
		for i in range(len(nd) - 1, -1, -1):
			print(nd[i], end=' ')
	else:
		print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
a = list(map(int, input().split()))
a.sort()
a = a[::-1]
dec = []
inc = [-1]
dec.append(a[0])
for i in a[1:]:
	if dec[-1] != i:
		dec.append(i)
	elif inc[-1] != i:
		inc.append(i)
if len(inc) + len(dec) - 1 == n:
	print('YES')
	print(len(inc) - 1)
	if len(inc) != 1:
		for i in inc[:0:-1]:
			print(i, end=' ')
		print(' ')
	else:
		print(' ')
	print(len(dec))
	for i in dec:
		print(i, end=' ')
else:
	print('NO')


import math
import bisect

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, x, y) = egcd(b % a, a)
		return (g, y - b // a * x, x)

def mulinv(b, n):
	(g, x, _) = egcd(b, n)
	if g == 1:
		return x % n
primes = []

def isprime(n):
	for d in range(2, int(math.sqrt(n)) + 1):
		if n % d == 0:
			return False
	return True

def argsort(ls):
	return sorted(range(len(ls)), key=ls.__getitem__)

def f(p=0):
	if p == 1:
		return map(int, input().split())
	elif p == 2:
		return list(map(int, input().split()))
	else:
		return int(input())
n = f()
dl = [0] * (2 * 10 ** 5 + 1)
cl = sorted(f(2))
for i in range(n):
	dl[cl[i]] += 1
	if dl[cl[i]] > 2:
		print('NO')
		exit()
a = []
b = []
for i in range(n):
	if dl[cl[i]] == 2:
		a.append(cl[i])
		dl[cl[i]] -= 1
	else:
		b.append(cl[i])
print('YES')
t = len(a)
print(t)
print(*a)
b = b[::-1]
s = len(b)
print(s)
print(*b)


import collections

def solve():
	N = int(input())
	A = list(map(int, input().split()))
	c = collections.Counter(A)
	for k in c.keys():
		if c[k] >= 3:
			print('NO')
			return
	ck = sorted(c.keys())
	a1 = []
	a2 = []
	for k in ck:
		if c[k] >= 2:
			a2.append(k)
		a1.append(k)
	print('YES')
	print(len(a1))
	print(' '.join(map(str, a1)))
	print(len(a2))
	print(' '.join(map(str, reversed(a2))))
solve()


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	n = int(input())
	a = list(map(int, input().split()))
	d = collections.Counter(a)
	s = set()
	for k in d.keys():
		if d[k] > 2:
			print('NO')
			return
		if d[k] == 2:
			s.add(k)
	(inc, dec) = ([], [])
	for x in a:
		if d[x] > 0:
			if x in s:
				inc.append(x)
				d[x] -= 1
			dec.append(x)
			d[x] -= 1
	print('YES')
	print(len(inc))
	print(' '.join([str(x) for x in sorted(inc)]))
	print(len(dec))
	print(' '.join([str(x) for x in sorted(dec, reverse=True)]))
main()


def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	arr = sorted(arr)
	for i in range(n):
		arr[i] = [arr[i], 1]
	a = []
	a.append(arr[0][0])
	arr[0][1] = 0
	b = []
	for i in range(1, n):
		if arr[i][0] > a[len(a) - 1]:
			a.append(arr[i][0])
			arr[i][1] = 0
	for i in range(n - 1, 0, -1):
		if arr[i][1] == 1:
			if len(b) == 0 or b[len(b) - 1] > arr[i][0]:
				b.append(arr[i][0])
				arr[i][1] = 0
			else:
				print('NO')
				return
	print('YES')
	print(len(a))
	for el in a:
		print(el, end=' ')
	print()
	print(len(b))
	for el in b:
		print(el, end=' ')
solve()


n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
increasing = [-1]
decreasing = [1000000.0]
c = 0
for i in range(len(a)):
	if a[i] > increasing[len(increasing) - 1]:
		increasing.append(a[i])
		a[i] = -1
for i in a[::-1]:
	if i < decreasing[len(decreasing) - 1] and i != -1:
		decreasing.append(i)
increasing.pop(0)
decreasing.pop(0)
if len(increasing) + len(decreasing) != n:
	print('NO')
if len(increasing) + len(decreasing) == n:
	print('YES')
	print(len(increasing))
	for i in increasing:
		print(i, end=' ')
	print()
	print(len(decreasing))
	for i in decreasing:
		print(i, end=' ')
	print()


import sys

def input():
	return sys.stdin.readline().strip()

def print(*x, sep=' ', end='\n'):
	return sys.stdout.write(sep.join(map(str, x)) + end)

def read():
	return sys.stdin.read()

def get():
	return (int(input()), [int(i) for i in input().split()])

def out(*arg):
	if type(arg[0]) == list:
		for i in arg[0]:
			print(i)
	else:
		print(arg)

def main():
	(n, a) = get()
	a.sort()
	down = []
	cnt = {}
	for i in a:
		if i not in cnt:
			cnt[i] = 0
		cnt[i] += 1
		if cnt[i] > 2:
			print('NO')
			return 0
	i = n - 1
	while i > -1:
		if i == n - 1 or a[i] < down[-1]:
			down.append(a[i])
		else:
			counter = 0
			while i > -1 and a[i] != a[i + 1]:
				i -= 1
				counter += 1
				if counter > 2:
					print('NO')
					return 0
			if i > -1 and a[i] != a[i + 1]:
				down.append(a[i])
		i -= 1
	up = []
	for i in down:
		x = cnt[i]
		x -= 1
		if x == 1:
			up.append(i)
	up.sort()
	print('YES')
	print(len(up))
	print(*up)
	print(len(down))
	print(*down)
main()


n = int(input())
l = list(map(int, input().split()))
a = {}
b = {}
for i in l:
	if i not in a:
		a[i] = 1
	elif i not in b:
		b[i] = 1
	else:
		print('NO')
		exit(0)
print('YES')
a = list(a.keys())
a = list(sorted(a))
print(len(a))
print(' '.join(list(map(str, a))))
b = list(b.keys())
b = list(sorted(b, reverse=True))
print(len(b))
print(' '.join(list(map(str, b))))


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()


from sys import *

def isstrogaya(l):
	i1 = -1
	r = True
	for i in l:
		if i <= i1:
			r = False
			break
		i1 = i
	return r
input()
q = sorted(list(map(int, input().split())))
one = []
two = []
l = True
for i in q:
	if l:
		l = False
		one.append(i)
		continue
	else:
		l = True
		two.append(i)
		continue
if isstrogaya(one) and isstrogaya(two):
	print('Yes')
	print(len(one))
	print(*one)
	print(len(two))
	print(*two[::-1])
else:
	print('No')


n = int(input())
l = [int(i) for i in input().split()]
d = dict()
for i in l:
	if i not in d:
		d[i] = 1
	else:
		d[i] += 1
a = []
b = []
flag = 1
for i in d:
	if d[i] == 1:
		a.append(i)
	elif d[i] == 2:
		a.append(i)
		b.append(i)
	else:
		print('NO')
		flag = 0
		break
if flag:
	print('YES')
	a.sort()
	print(len(a))
	print(*a)
	b.sort(reverse=True)
	print(len(b))
	print(*b)


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()))
s = set()
test = set()
up = []
down = []
for i in a:
	if i in test:
		print('NO')
		exit()
	if i in s:
		test.add(i)
		down.append(i)
	else:
		s.add(i)
		up.append(i)
print('YES')
print(len(up))
print(*sorted(up))
print(len(down))
print(*sorted(down, reverse=True))


n = int(input(''))
a = list(map(int, input().split()))
c = []
ii = []
d = []
ans = 1
for i in range(200005):
	c.append(0)
o = []
s = 0
for i in range(len(a)):
	c[a[i]] += 1
	if c[a[i]] > 2:
		ans = 0
		break
	if c[a[i]] == 2:
		d.append(a[i])
if ans == 0:
	print('NO')
else:
	d.sort(reverse=True)
	for i in range(len(c)):
		if c[i] == 1 or c[i] == 2:
			ii.append(i)
	ii.sort()
	print('YES')
	if len(ii) == 0:
		print('0')
		print()
	else:
		print(len(ii))
		for i in range(len(ii)):
			print(ii[i], end=' ')
		print()
	if len(d) == 0:
		print('0')
		print()
	else:
		print(len(d))
		for i in range(len(d)):
			print(d[i], end=' ')
		print()


import math
from collections import defaultdict, Counter, deque

def primeFactor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i ** 2 <= n:
		if n % i == 0:
			return i
		i += 1
	return n

def main():
	n = int(input())
	arr = list(map(int, input().split()))
	inc = []
	dec = []
	count = defaultdict(int)
	for i in range(n):
		if count[arr[i]] == 2:
			print('NO')
			return
		elif count[arr[i]] == 0:
			inc.append(arr[i])
		elif count[arr[i]] == 1:
			dec.append(arr[i])
		count[arr[i]] += 1
	inc.sort()
	dec.sort(reverse=True)
	print('YES')
	print(len(inc))
	print(*inc)
	print(len(dec))
	print(*dec)
t = 1
for _ in range(t):
	main()


n = int(input())
a = list(map(int, input().split()))
dic = {i: 0 for i in a}
cond = True
for i in range(n):
	if dic[a[i]] == 2:
		print('No')
		cond = False
		break
	else:
		dic[a[i]] += 1
if cond:
	increasing = []
	decreasing = []
	for i in range(n):
		if dic[a[i]] == 2:
			decreasing.append(a[i])
			dic[a[i]] -= 1
		else:
			increasing.append(a[i])
	increasing.sort()
	decreasing.sort()
	decreasing = decreasing[::-1]
	print('Yes')
	print(len(increasing))
	for i in range(len(increasing)):
		if i != len(increasing) - 1:
			print(increasing[i], end=' ')
		else:
			print(increasing[i])
	print(len(decreasing))
	for i in decreasing:
		print(i, end=' ')


import sys
import math
import bisect

def solve(A, B):
	n = len(A)
	A.sort()
	for i in range(2, n):
		if A[i] == A[i - 1] and A[i] == A[i - 2]:
			return False
	C = A.copy()
	A.clear()
	for i in range(n):
		if i % 2 == 0:
			A.append(C[i])
		else:
			B.append(C[i])
	B.reverse()
	return True

def main():
	n = int(input())
	A = list(map(int, input().split()))
	B = []
	if solve(A, B):
		print('YES')
		print(len(A))
		print(' '.join((str(a) for a in A)))
		print(len(B))
		print(' '.join((str(a) for a in B)))
	else:
		print('NO')
main()


from collections import Counter
n = int(input())
lista = str(input()).split()
lista = [int(i) for i in lista]
dicio = Counter(lista)
lista = []
tam = 0
lista2 = []
tam2 = 0
for a in sorted(dicio.keys()):
	if dicio[a] > 2:
		print('NO')
		exit(0)
	if dicio[a] == 2:
		lista.append(a)
		tam = tam + 1
		dicio[a] = dicio[a] - 1
	if dicio[a] == 1:
		lista2.append(a)
		tam2 = tam2 + 1
		dicio[a] = dicio[a] - 1
print('YES')
print(tam)
for i in lista:
	print(i, end=' ')
print('')
print(tam2)
for i in reversed(lista2):
	print(i, end=' ')


n = int(input())
arr = list(map(int, input().split()))
m = {}
f = 0
for i in arr:
	if i in m:
		if m[i] >= 2:
			f = 1
			break
		else:
			m[i] += 1
	else:
		m[i] = 1
if f:
	print('NO')
else:
	f = []
	s = []
	print('YES')
	k = list(m.keys())
	v = list(m.values())
	for i in range(len(v)):
		if v[i] == 2:
			f.append(k[i])
			s.append(k[i])
		else:
			s.append(k[i])
	print(len(f))
	f.sort()
	print(*f)
	s.sort(reverse=True)
	print(len(s))
	print(*s)


from collections import Counter
n = int(input())
a = [int(i) for i in input().split(' ') if i != '']
inc = []
dec = []
c = {}

def part():
	for i in a:
		c[i] = c.get(i, 0) + 1
		if c[i] > 2:
			return False
	for (key, val) in sorted(c.items()):
		if val == 2:
			inc.append(key)
			dec.insert(0, key)
		else:
			inc.append(key)
	return True
f = part()
if f:
	print('YES')
	print(len(inc))
	print(' '.join(map(str, inc))) if len(inc) else print()
	print(len(dec))
	print(' '.join(map(str, dec))) if len(dec) else print()
else:
	print('NO')


d = {}
n = int(input())
s1 = []
s2 = []
l = list(map(int, input().split()))
for i in l:
	d[i] = d.get(i, 0) + 1
lol = 0
for i in d:
	if d[i] == 1:
		s1.append(i)
	elif d[i] == 2:
		s1.append(i)
		s2.append(i)
	else:
		lol = 1
		break
if lol == 1:
	print('No')
else:
	print('Yes')
	print(len(s1))
	s1.sort()
	print(*s1)
	print(len(s2))
	s2.sort(reverse=True)
	print(*s2)


def print_list(seq):
	if len(seq) == 0:
		return
	for x in seq:
		print(x, end=' ')
	print('')

def finding_seq(n, seq):
	refer = {}
	desc_list = []
	for x in seq:
		if x not in refer:
			refer[x] = 1
		else:
			refer[x] += 1
			if refer[x] > 2:
				print('NO')
				return
	for (i, j) in refer.items():
		if j == 2:
			desc_list.append(i)
	asc_list = sorted(list(refer.keys()))
	if len(desc_list) > 1:
		desc_list.sort()
		desc_list.reverse()
	print('YES')
	print(len(asc_list))
	print_list(asc_list)
	print(len(desc_list))
	print_list(desc_list)
n = int(input())
seq = list(map(int, input().split()))
finding_seq(n, seq)


n = int(input())
a = [int(s) for s in input().split()]
d = dict()
for i in a:
	x = d.get(i, 0)
	if x == 0:
		d[i] = 1
	else:
		d[i] += 1
up = []
down = []
for i in d.keys():
	k = d[i]
	if k == 1:
		up.append(i)
	elif k == 2:
		up.append(i)
		down.append(i)
	else:
		print('NO')
		exit()
up.sort()
down.sort(reverse=True)
print('YES')
print(len(up))
print(' '.join([str(i) for i in up]))
print(len(down))
print(' '.join([str(i) for i in down]))


n = int(input())
arr = list(map(int, input().split()))
ans = True
arr.sort()
inc = []
dec = [arr[-1]]
c = 1
for i in range(n - 2, -1, -1):
	if arr[i] == arr[i + 1]:
		c += 1
		inc.append(arr[i])
		if c == 3:
			print('NO')
			ans = False
			break
	elif arr[i] != arr[i + 1]:
		c = 1
		dec.append(arr[i])
if ans:
	print('YES')
	print(len(inc))
	print(*inc[-1::-1])
	print(len(dec))
	print(*dec)


import math
from collections import deque

def split(arr):
	arr.sort()
	(a, b) = (deque([]), deque([]))
	prev = None
	prev_count = 0
	for x in arr:
		if x == prev:
			prev_count += 1
			if prev_count > 2:
				print('NO')
				return
			b.appendleft(x)
		else:
			prev_count = 1
			prev = x
			a.append(x)
	print('YES')
	print(len(a))
	for x in a:
		print(x, end=' ')
	print('')
	print(len(b))
	for x in b:
		print(x, end=' ')
n = int(input())
arr = list(map(int, input().split()))
split(arr)


N = int(input())
numbers = sorted([int(x) for x in input().split(' ')])
counter = [0] * (2 * 10 ** 5 + 1)
increasing = []
decreasing = []
for i in range(len(numbers)):
	counter[numbers[i]] += 1
	if counter[numbers[i]] > 2:
		print('NO')
		exit()
	if counter[numbers[i]] > 1:
		increasing.append(numbers[i])
	else:
		decreasing.append(numbers[i])
print('YES')
print(len(increasing))
print(*increasing, sep=' ')
print(len(decreasing))
print(*decreasing[::-1], sep=' ')


from collections import defaultdict as DD
from bisect import bisect_left as BL
from bisect import bisect_right as BR
from itertools import combinations as IC
from itertools import permutations as IP
from random import randint as RI
import sys
MOD = pow(10, 9) + 7

def IN(f=0):
	if f == 0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())
n = IN(1)
a = IN()
d = DD(int)
r = []
t = []
f = 0
for i in range(n):
	d[a[i]] += 1
	if d[a[i]] > 2:
		f = 1
if f == 1:
	print('NO')
else:
	for i in d:
		if d[i] == 1:
			r.append(i)
		else:
			r.append(i)
			t.append(i)
	print('YES')
	print(len(r))
	r.sort()
	print(*r)
	print(len(t))
	t.sort(reverse=True)
	print(*t)


def getElem(n, arr):
	arr.sort()
	eveAr = []
	oddAr = []
	for i in range(n):
		if i % 2 == 0:
			eveAr.append(arr[i])
		else:
			oddAr.append(arr[i])
	eN = len(eveAr)
	oN = len(oddAr)
	oddAr.sort(reverse=True)
	if eN != len(set(eveAr)) or oN != len(set(oddAr)):
		return 'NO'
	return ('YES', eveAr, eN, oddAr, oN)
n = int(input())
arr = list(map(int, input().split()))
op = getElem(n, arr)
if op == 'NO':
	print('NO')
else:
	res = ''
	(yes, eveAr, eN, oddAr, oN) = op
	print(yes)
	print(eN)
	for i in eveAr:
		res += str(i) + ' '
	print(res)
	res = ''
	print(oN)
	for j in oddAr:
		res += str(j) + ' '
	print(res)


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
flag = True
count = 1
t = arr[0]
ans1 = [arr[0]]
ans2 = []
for i in range(1, len(arr)):
	if arr[i] == t:
		count += 1
	else:
		count = 1
	t = arr[i]
	if count > 2:
		print('NO')
		flag = False
		break
	elif count == 2:
		ans2.append(arr[i])
	else:
		ans1.append(arr[i])
if flag:
	print('YES')
	print(len(ans1))
	print(*ans1)
	print(len(ans2))
	print(*ans2[::-1])


m = int(input())
a = list(map(int, input().split()))
a.sort()
inc = []
dec = []
mark = []
l = 0
i = 0
l1 = 0
while i < len(a):
	mark.append(0)
	i += 1
i = 1
mark[0] = 1
inc.append(0)
while i < len(a):
	if a[i] > a[l]:
		mark[i] = 1
		l = i
		inc.append(i)
	else:
		l1 = i
	i += 1
i = len(a) - 1
l = l1
if mark[l1] == 0:
	dec.append(l1)
while i >= 0:
	if mark[i] == 0 and a[i] < a[l]:
		mark[i] = 1
		l = i
		dec.append(i)
	i -= 1
if len(dec) + len(inc) == m:
	print('YES')
	i = 0
	print(len(inc))
	while i < len(inc):
		print(a[inc[i]], end=' ')
		i += 1
	print()
	print(len(dec))
	i = 0
	while i < len(dec):
		print(a[dec[i]], end=' ')
		i += 1
else:
	print('NO')


n = int(input())
numbers = list(map(int, input().split(' ')))
numbers = sorted(numbers)

def find_sequences(numbers):
	count = [0] * 200001
	for i in numbers:
		count[i] += 1
	a = list()
	b = list()
	for (i, e) in enumerate(count):
		if e == 1:
			a.append(i)
		if e == 2:
			a.append(i)
			b.append(i)
		if e >= 3:
			print('No')
			return
	print('Yes')
	print(len(a))
	print(' '.join(map(str, a)))
	print(len(b))
	print(' '.join(map(str, b[::-1])))
	return
find_sequences(numbers)


n = int(input())
A = list(map(int, input().rstrip().split()))
inc_seq = []
dec_seq = []
res = 'YES'
belonging = dict()
for a in A:
	try:
		b = belonging[a]
	except KeyError:
		b = None
	if b == 'both':
		res = 'NO'
		break
	elif b == 'inc':
		dec_seq.append(a)
		belonging[a] = 'both'
	elif b == 'dec':
		inc_seq.append(a)
		belonging[a] = 'both'
	else:
		dec_seq.append(a)
		belonging[a] = 'dec'
print(res)
if res == 'YES':
	print(len(inc_seq))
	inc_seq = sorted(inc_seq)
	print(' '.join(map(str, inc_seq)))
	print(len(dec_seq))
	dec_seq = sorted(dec_seq, reverse=True)
	print(' '.join(map(str, dec_seq)))


x = int(input())
y = list(map(int, input().split(' ')))
y = sorted(y)
t = True
c = 0
m = 0
q = y[0]
a = [y[0]]
b = []
for i in range(1, len(y)):
	if y[i] == q:
		c += 1
		t = not t
	else:
		c = 0
	q = y[i]
	m = max(m, c)
	if t:
		a.append(y[i])
	else:
		b.append(y[i])
if m > 1:
	print('NO')
else:
	print('YES')
	print(len(a))
	print(' '.join(list(map(str, a))))
	print(len(b))
	print(' '.join(list(map(str, reversed(b)))))


import sys, math, queue
sys.setrecursionlimit(1000000)
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')
		exit()
inc = sorted(inc)
dec = sorted(dec, reverse=True)
print('YES')
print(len(inc))
print(*inc)
print(len(dec))
print(*dec)


from os import path
import sys
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def solve():
	n = ii()
	a = li()
	x = [0] * (max(a) + 1)
	for i in a:
		x[i] += 1
	if max(x) > 2:
		print('NO')
		exit(0)
	a = []
	b = []
	for i in range(len(x)):
		if x[i] == 1:
			a.append(i)
		if x[i] == 2:
			a.append(i)
			b.append(i)
	print('YES')
	print(len(a))
	print(*a)
	b.reverse()
	print(len(b))
	print(*b)
solve()


n = int(input())
nums = list(map(int, input().split()))
incr = []
decr = []
nums.sort()
flag = True
for i in nums:
	if len(incr) > 0:
		if incr[-1] == i:
			if len(decr) > 0:
				if decr[-1] == i:
					flag = False
					print('NO')
					break
				else:
					decr.append(i)
			else:
				decr.append(i)
		else:
			incr.append(i)
	else:
		incr.append(i)
if flag:
	print('YES')
	print(len(incr))
	print(*incr)
	print(len(decr))
	print(*decr[::-1])


import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import Counter

def main():
	(n, *a) = map(int, read().split())
	a_ac = Counter(a)
	if a_ac.most_common()[0][1] > 2:
		print('NO')
	else:
		a1 = [k for (k, v) in a_ac.items() if v == 2]
		a2 = list(set(a))
		a1.sort()
		a2.sort(reverse=True)
		print('YES')
		print(len(a1))
		print(*a1, sep=' ')
		print(len(a2))
		print(*a2, sep=' ')
main()


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
s = list(set(a))
d = Counter(a)
da = []
for (x, y) in d.items():
	if y > 2:
		print('No')
		break
	if y == 2:
		da.append(x)
else:
	if da:
		l = len(da)
	else:
		l = 0
	print('Yes')
	print(n - l)
	print(*sorted(s))
	print(l)
	if l == 0:
		print()
	else:
		print(*sorted(da, reverse=True))


def ev():
	n = int(input())
	a = list(map(int, input().split()))
	p1 = set()
	p2 = set()
	for i in range(n):
		if not a[i] in p1:
			p1.add(a[i])
		elif not a[i] in p2:
			p2.add(a[i])
		else:
			print('NO')
			return
	print('YES')
	print(len(p1))
	for elem in sorted(p1):
		print(elem, end=' ')
	print()
	print(len(p2))
	for elem in sorted(p2, reverse=True):
		print(elem, end=' ')
	print()
ev()


n = int(input())
a = sorted([int(i) for i in input().split()])
b1 = []
b2 = []
ok = True
for i in a:
	if len(b1) == 0 or b1[len(b1) - 1] != i:
		b1.append(i)
	elif len(b2) == 0 or b2[len(b2) - 1] != i:
		b2.append(i)
	else:
		ok = False
		break
if ok:
	print('YES')
	print(len(b1))
	print(*b1)
	print(len(b2))
	print(*sorted(b2, reverse=True))
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
v = []
y = []
d = {}
for c in a:
	d[c] = d.get(c, 0) + 1
for x in d:
	if d[x] > 2:
		print('NO')
		exit(0)
	if d[x] == 2:
		v.append(x)
		y.append(x)
	else:
		v.append(x)
print('YES')
print(len(v))
print(*sorted(v))
print(len(y))
y.sort(reverse=True)
print(*y)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	for i in range(n):
		if d.get(a[i]) == None:
			d[a[i]] = 1
		else:
			d[a[i]] += 1
	arr = []
	arr2 = []
	for x in d:
		if d[x] >= 3:
			print('NO')
			return
		elif d[x] > 1:
			arr.append(x)
		arr2.append(x)
	arr.sort()
	arr2.sort(reverse=True)
	print('YES')
	print(len(arr))
	for x in arr:
		print(x, end=' ')
	print()
	print(len(arr2))
	for x in arr2:
		print(x, end=' ')
	print()
	return
main()


n = int(input())
a = list(map(int, input().split()))
a.sort()
inc = []
dec = []
ri = -1
rd = -1
v = 1
for i in a:
	if i != rd:
		dec.append(i)
		rd = i
	elif i != ri:
		inc.append(i)
		ri = i
	else:
		v = 0
		print('NO')
		break
if v == 1:
	print('YES')
	dec.reverse()
	print(len(inc))
	for i in inc:
		print(i, end=' ')
	print()
	print(len(dec))
	for i in dec:
		print(i, end=' ')


n = int(input())
lis = list(map(int, input().split()))
has = [0] * 200002
dec = []
inc = []
for i in lis:
	if has[i] == 0:
		inc.append(i)
		has[i] = 1
	elif has[i] == 1:
		dec.append(i)
		has[i] = 2
	elif has[i] == 2:
		print('NO')
		exit()
inc.sort()
dec.sort(reverse=True)
print('YES')
print(len(inc))
print(*inc)
print(len(dec))
print(*dec)


from collections import *
import sys
import copy
input = sys.stdin.readline
N: int = int(input())
a: [int] = [int(x) for x in input().split()]
cnt: [int] = [0] * 200020
for x in a:
	cnt[x] += 1
for x in cnt:
	if x > 2:
		print('No')
		exit()
(inc, dec) = ([], [])
for (i, x) in enumerate(cnt):
	if x > 0:
		cnt[i] -= 1
		inc.append(i)
for (i, x) in enumerate(cnt):
	if x > 0:
		cnt[i] -= 1
		dec.append(i)
print('Yes')
print(len(inc))
print(' '.join(map(str, inc)))
print(len(dec))
print(' '.join(map(str, reversed(dec))))


n = int(input())
arr = list(map(int, input().split()))
cnt = [0] * (2 * 10 ** 5 + 1)
for i in arr:
	cnt[i] += 1
	if cnt[i] == 3:
		print('NO')
		break
else:
	fi = []
	se = []
	for i in range(len(cnt)):
		if cnt[i] == 2:
			cnt[i] -= 1
			fi.append(i)
	fi.sort()
	for i in range(len(cnt)):
		if cnt[i] == 1:
			se.append(i)
	se.sort(reverse=True)
	print('YES')
	print(len(fi))
	print(*fi)
	print(len(se))
	print(*se)


n = int(input())
s = str(input())
lt = s.split(' ')
l = []
d = []
for i in range(200001):
	d.append(0)
l2 = []
for i in range(n):
	l.append(int(lt[i]))
for i in l:
	if d[i] == 0:
		l2.append(i)
	d[i] += 1
ans = 'YES'
for i in l:
	if d[i] > 2:
		ans = 'NO'
		break
if ans == 'NO':
	print(ans)
else:
	l2.sort()
	inc = []
	dec = []
	for i in l2:
		inc.append(i)
		d[i] -= 1
	for i in range(len(l2) - 1, -1, -1):
		if d[l2[i]] != 0:
			dec.append(l2[i])
	print(ans)
	print(len(inc))
	s1 = ''
	for i in inc:
		s1 += str(i) + ' '
	print(s1)
	print(len(dec))
	s2 = ''
	for i in dec:
		s2 += str(i) + ' '
	print(s2)


n = int(input())
l = sorted(map(int, input().split()))
inc = []
dec = []
visited = [False] * n
for i in range(n):
	if not inc or inc[-1] != l[i]:
		inc.append(l[i])
		visited[i] = True
for i in range(n):
	if not visited[i] and (not dec or dec[-1] != l[i]):
		dec.append(l[i])
		visited[i] = True
for i in range(n):
	if not visited[i]:
		print('NO')
		exit()
dec.reverse()
print('YES')
print(len(inc))
for i in inc:
	print(i, end=' ')
print()
print(len(dec))
for i in dec:
	print(i, end=' ')


from collections import *
n = int(input())
d = Counter(map(int, input().split()))
if max(d.values()) > 2:
	print('NO')
else:
	print('YES')
	b = sorted((i for i in d if d[i] > 1))[::-1]
	print(len(d), *sorted(d), len(b), *b)


n = int(input())
s = list(map(int, input().split()))
s.sort()
a = -1
count = 0
yn = True
for i in s:
	if i == a:
		count += 1
	else:
		a = i
		count = 1
	if count >= 3:
		yn = False
		break
if yn:
	print('YES')
	inc = []
	dec = []
	a = -1
	for i in s:
		if i == a:
			dec.append(i)
		else:
			a = i
			inc.append(i)
	dec.sort(reverse=True)
	print(len(inc))
	print(' '.join(list(map(str, inc))))
	print(len(dec))
	print(' '.join(list(map(str, dec))))
else:
	print('NO')


n = int(input())
l = sorted(list(map(int, input().split())))
d = {}
l1 = []
for i in l:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
if max(d.values()) > 2:
	print('NO')
	exit()
print('YES')
z = l[::2]
y = l[1::2]
print(len(z))
print(*z)
print(len(y))
print(*y[::-1])


n = int(input())
a = [int(i) for i in input().split()]
from collections import Counter
c = Counter(a)
if max(c.values()) > 2:
	print('NO')
else:
	print('YES')
	if max(c.values()) == 1:
		print(n)
		for i in sorted(c.keys()):
			print(i, end=' ')
		print('\n0')
	else:
		ans1 = sorted(c.keys())
		print(len(ans1))
		for i in ans1:
			print(i, end=' ')
		ans2 = sorted(list(set([i for i in a if c[i] > 1])), reverse=True)
		print('\n' + str(len(ans2)))
		for i in ans2:
			print(i, end=' ')


import collections
import itertools
import sys
from collections import defaultdict, Counter
from math import sqrt, ceil
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def c(b, n):
	return b - b // n

def main():
	d = inp()
	v = inlt()
	freq = defaultdict(lambda : 0)
	for vv in v:
		freq[vv] += 1
	for (k, v) in freq.items():
		if v > 2:
			print('NO')
			return
	res1 = []
	res2 = []
	for (k, v) in freq.items():
		if v == 1:
			res1.append(k)
		else:
			res1.append(k)
			res2.append(k)
	res1.sort()
	res2.sort(reverse=True)
	print('YES')
	print(len(res1))
	print(' '.join([str(vv) for vv in res1]))
	print(len(res2))
	print(' '.join([str(vv) for vv in res2]))
main()


n = int(input())
li = list(map(int, input().split(' ', n)[:n]))
li.sort()
lia = []
lib = []
uf = 0
fl = 0
for i in range(n):
	if i == 0:
		lia.append(li[i])
	elif fl == 0 and li[i - 1] == li[i]:
		fl = 1
		lib.append(li[i])
	elif fl == 1 and li[i - 1] == li[i]:
		uf = 1
		break
	else:
		lia.append(li[i])
		fl = 0
if uf == 0:
	print('YES')
	lia = [str(i) for i in lia]
	print(len(lia))
	print(' '.join(lia))
	print(len(lib))
	if len(lib) == 0:
		print()
	else:
		lib.sort(reverse=True)
		lib = [str(i) for i in lib]
		print(' '.join(lib))
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
d = {}
for v in a:
	if v in d:
		if d[v] > 1:
			print('NO')
			exit()
		else:
			d[v] += 1
	else:
		d[v] = 1
(s, l) = ([], [])
for v in sorted(d):
	if d[v] == 2:
		l.append(v)
		s.append(v)
	else:
		l.append(v)
print('YES')
print(len(l))
print(*l)
print(len(s))
print(*s[::-1])


n = int(input())
l = [*map(int, input().split())]
tmp1 = {}
tmp2 = {}
f = True
for i in l:
	if tmp1.get(i, -1) == -1:
		tmp1[i] = 1
	elif tmp2.get(i, -1) == -1:
		tmp2[i] = 1
	else:
		f = False
		print('NO')
		break
if f:
	a = []
	print('YES')
	print(len(tmp2))
	for i in tmp2.keys():
		a.append(i)
	print(*sorted(a), sep=' ')
	a = []
	print(len(tmp1))
	for i in tmp1.keys():
		a.append(i)
	print(*sorted(a, reverse=True), sep=' ')


def solve(values):
	values = sorted(values)
	taken = [False] * len(values)
	inc = [values[0]]
	taken[0] = True
	dec = []
	taken_total = 1
	for i in range(1, len(values)):
		if values[i] > inc[-1]:
			taken[i] = True
			inc.append(values[i])
			taken_total += 1
	for i in reversed(range(1, len(values))):
		if not taken[i] and (len(dec) == 0 or values[i] < dec[-1]):
			dec.append(values[i])
			taken_total += 1
			taken[i] = True
	if taken_total != len(values):
		return (False, None)
	return (True, (inc, dec))

def main() -> None:
	n = int(input())
	values = list(map(int, input().split()))
	(result, arrays) = solve(values)
	if not result:
		print('NO')
	else:
		print('YES')
		(inc, dec) = arrays
		print(len(inc))
		if len(inc) == 0:
			print()
		else:
			print(*inc)
		print(len(dec))
		if len(dec) == 0:
			print()
		else:
			print(*dec)
main()


n = int(input())
a = list(map(int, input().split()))
a.sort()
b = []
c = []
k = 0
l = 0
for i in range(len(a) - 1):
	if a[i] == a[i + 1]:
		c.append(a[i + 1])
	else:
		b.append(a[i])
b.append(a[len(a) - 1])
b.sort()
c.sort()
c.reverse()
for i in range(len(b) - 1):
	if b[i] == b[i + 1]:
		k += 1
for i in range(len(c) - 1):
	if c[i] == c[i + 1]:
		l += 1
if l > 0 or k > 0:
	print('No')
else:
	print('Yes')
	print(len(b))
	print(*b)
	print(len(c))
	print(*c)


def f(l):
	l.sort()
	output1 = []
	output2 = []
	for item in l:
		if len(output1) == 0 or output1[-1] != item:
			output1.append(item)
		elif len(output2) == 0 or output2[-1] != item:
			output2.append(item)
		else:
			return ['NO']
	output2.reverse()
	return ['YES', len(output1), ' '.join([str(x) for x in output1]), len(output2), ' '.join([str(x) for x in output2])]
n = input()
for item in f([int(x) for x in input().split()]):
	print(item)


n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
v = 1
for i in range(n - 2):
	if l[i] == l[i + 1] and l[i + 1] == l[i + 2]:
		print('NO')
		v = 0
		break
inc = []
dec = []
if v == 1:
	if n == 1:
		dec.append(l[0])
	else:
		for i in range(n - 1):
			if l[i] == l[i + 1]:
				inc.append(l[i])
			else:
				dec.append(l[i])
			if i == n - 2:
				dec.append(l[i + 1])
if v == 1:
	print('YES')
	print(len(inc))
	print(*inc)
	print(len(dec))
	d = reversed(dec)
	print(*d)


mod = 10 ** 9 + 7
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
n = ii()
l = sorted(il())
(inc, dec) = ([], [])
for i in range(1, n):
	if l[i - 1] == l[i]:
		dec.insert(0, l[i])
inc = sorted(list(set(l)))
dec = sorted(list(set(dec)), reverse=True)
lni = len(inc)
dni = len(dec)
if lni + dni != n:
	print('NO')
else:
	print('YES')
	print(lni)
	print(*inc)
	print(dni)
	print(*dec)


n = int(input())
arr = map(int, input().split(' '))
arr = sorted(arr, reverse=True)
(inc, dec) = ([], [])
maxi = arr[0]
dec.append(arr[0])
for j in range(1, n):
	if arr[j] != arr[j - 1]:
		dec.append(arr[j])
	else:
		inc.append(arr[j])
inc = inc[::-1]
if len(inc) + len(dec) == n and len(set(inc)) == len(inc) and (len(set(dec)) == len(dec)):
	print('YES')
	print(len(inc))
	print(*inc)
	print(len(dec))
	print(*dec)
else:
	print('NO')


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
elem_map = defaultdict(lambda : list())
for ai in a:
	elem_map[ai].append(ai)
first = list()
second = list()
cannot = False
for key in elem_map:
	values = elem_map[key]
	if len(values) > 2:
		cannot = True
		break
	elif len(values) == 2:
		first.append(key)
		second.append(key)
	else:
		first.append(key)
if cannot:
	print('NO')
else:
	print('YES')
	first = sorted(first)
	second = sorted(second, reverse=True)
	print(len(first))
	print(' '.join([str(x) for x in first]))
	print(len(second))
	print(' '.join([str(x) for x in second]))


n = int(input())
m = list(map(int, input().split()))
mas = [0] * (2 * 10 ** 5 + 3)
m1 = []
m2 = []
l1 = 0
l2 = 0
for i in m:
	if mas[i] == 0:
		m1.append(i)
		mas[i] += 1
		l1 += 1
	elif mas[i] == 1:
		m2.append(i)
		l2 += 1
		mas[i] += 1
	else:
		print('NO')
		exit()
print('YES')
print(l1)
print(*sorted(m1))
print(l2)
print(*sorted(m2, reverse=True))


n = int(input())
a = list(map(int, input().split()))
a.sort()
cnt = 1
s = []
y = []
f = True
s.append(a[0])
for i in range(1, len(a)):
	if a[i] == a[i - 1]:
		y.append(a[i])
		cnt += 1
		if cnt == 3:
			print('NO')
			f = False
			break
	else:
		s.append(a[i])
		cnt = 1
if f:
	print('YES')
	print(len(s))
	for i in range(len(s)):
		print(s[i], end=' ')
	print()
	print(len(y))
	y.reverse()
	for i in range(len(y)):
		print(y[i], end=' ')
	print()


import sys
lines = sys.stdin.readlines()

def parse_arr(line):
	return list(map(int, line.split(' ')))
n = int(lines[0])
arr = parse_arr(lines[1])
mapi = {}
for num in arr:
	if num in mapi:
		mapi[num] += 1
	else:
		mapi[num] = 1
a = []
b = []
possible = True
for k in sorted(mapi.keys()):
	if mapi[k] > 2:
		possible = False
		break
	elif mapi[k] == 2:
		a.append(k)
		b.append(k)
	else:
		a.append(k)
if not possible:
	print('NO')
	exit(0)
sys.stdout.write('YES\n')
sys.stdout.write(str(len(a)) + '\n')
for i in a:
	sys.stdout.write(str(i) + ' ')
sys.stdout.write('\n')
b = list(reversed(b))
sys.stdout.write(str(len(b)) + '\n')
for i in b:
	sys.stdout.write(str(i) + ' ')
sys.stdout.write('\n')


from math import ceil, sqrt
from collections import defaultdict as dd
d = dd(lambda : 0)
from collections import Counter as C

def mp():
	return map(int, input().split())

def i():
	return int(input())
n = i()
l = list(mp())
for i in l:
	d[i] += 1
(v, q) = ([], [])
ans = 0
for i in d:
	if d[i] > 2:
		ans = 1
		break
	elif d[i] == 2:
		q.append(i)
		v.append(i)
	else:
		v.append(i)
v.sort()
q.sort()
q.reverse()
if ans == 1:
	print('NO')
else:
	print('YES')
	print(len(v))
	print(*v)
	print(len(q))
	print(*q)


import re, math, decimal, bisect, collections

def read():
	return input().strip()

def iread():
	return int(input().strip())

def viread():
	return [int(_) for _ in input().strip().split()]

def round(n):
	return int(n + 0.5)
n = iread()
arr = sorted(viread())
ctr = collections.Counter(arr)
for c in ctr:
	if ctr[c] > 2:
		print('NO')
		exit()
(asc, dsc) = (set(), set())
for i in arr:
	if i not in asc:
		asc.add(i)
	else:
		dsc.add(i)
print('YES')
print(len(asc))
print(*sorted(asc))
print(len(dsc))
print(*sorted(dsc, key=lambda x: -x))


n = int(input())
a = map(int, input().split())
x = set()
y = set()
flag = False
for c in a:
	if c not in x:
		x.add(c)
	elif c not in y:
		y.add(c)
	else:
		print('NO')
		flag = True
		break
if not flag:
	print('YES')
	print(len(x))
	print(*sorted(list(x)))
	print(len(y))
	print(*sorted(list(y), reverse=True))


N = int(input())
(setI, setD) = (set(), set())
L = list(map(int, input().split()))
f = True
for i in L:
	if i not in setI:
		setI.add(i)
	elif i not in setD:
		setD.add(i)
	else:
		f = False
		break
if not f:
	print('NO')
else:
	d = list(setD)
	i = list(setI)
	d.sort(reverse=True)
	i.sort()
	print('YES')
	print(len(i))
	for a in i:
		print(a, end=' ')
	print()
	print(len(d))
	for a in d:
		print(a, end=' ')


IN = input
rint = lambda : int(IN())
rlist = lambda : list(map(int, IN().split()))
n = rint()
a = rlist()
a.sort()
for i in range(1, n - 1):
	if a[i] == a[i - 1] and a[i] == a[i + 1]:
		print('NO')
		exit(0)
x = []
y = []
for i in range(n):
	if i < n - 1 and a[i] == a[i + 1]:
		x.append(a[i])
	else:
		y.append(a[i])
x.sort()
y.sort()
y.reverse()
print('YES')
print(len(x))
for c in x:
	print(c, end=' ')
print()
print(len(y))
for c in y:
	print(c, end=' ')


import string, copy

def solution(n, nums):
	i1 = set()
	i2 = set()
	for i in nums:
		if i not in i2:
			i2.add(i)
		elif i not in i1:
			i1.add(i)
		else:
			return 'No'
	return 'Yes\n%d\n%s\n%d\n%s' % (len(i1), ' '.join([str(i) for i in sorted(list(i1))]), len(i2), ' '.join([str(i) for i in sorted(list(i2), reverse=True)]))

def parser():
	n = int(input())
	nums = [int(s) for s in input().split(' ')]
	return (n, nums)

def output(s):
	print(s)

def main():
	args = parser()
	result = solution(*args)
	output(result)
main()


n = int(input())
ai = list(map(int, input().split()))
ai.sort()
ar = [ai[0]]
ar2 = []
if n > 1:
	ar2 += [ai[1]]
ans = True
for i in range(2, n):
	if ai[i] == ar[-1]:
		if ai[i] == ar2[-1]:
			ans = False
			break
		ar2 += [ai[i]]
	else:
		ar += [ai[i]]
if ans:
	print('YES')
	print(len(ar))
	for i in ar:
		print(i, end=' ')
	print()
	print(len(ar2))
	for i in range(len(ar2) - 1, -1, -1):
		print(ar2[i], end=' ')
	print()
else:
	print('NO')


import collections

def main():
	n = int(input())
	arr = map(int, input().split())
	(r1, r2) = ([], [])
	hash_t = {}
	for i in arr:
		if hash_t.get(i) == None:
			hash_t[i] = 0
		hash_t[i] += 1
	for (i, t) in hash_t.items():
		if t > 2:
			return (0, 0)
		if t == 1:
			r2.append(i)
		if t == 2:
			r1.append(i)
			r2.append(i)
	return (r1, r2)
(r1, r2) = main()
if r1 == 0 and r2 == 0:
	print('NO')
else:
	print('YES')
	print(len(r1))
	print(*sorted(r1))
	print(len(r2))
	print(*sorted(r2, reverse=True))


from collections import Counter
n = int(input())
s = list(map(int, input().split()))
c = Counter()
a = []
b = []
for x in s:
	c[x] += 1
	if c[x] == 3:
		print('NO')
		exit(0)
	if c[x] == 2:
		b.append(x)
	else:
		a.append(x)
a.sort()
b.sort()
b.reverse()
print('YES')
print(len(a))
print(' '.join([str(x) for x in a]))
print(len(b))
print(' '.join([str(x) for x in b]))


n = int(input())
ar = list(map(int, input().split()))
l1 = set()
l2 = set()
for i in ar:
	if i in l1:
		l2.add(i)
	else:
		l1.add(i)
if len(l1) + len(l2) == n:
	print('YES')
	print(len(l1))
	print(*sorted(l1))
	print(len(l2))
	print(*sorted(list(l2), reverse=True))
else:
	print('NO')


n = int(input().strip())
a = list((int(i) for i in input().strip().split(' ')))
a.sort()
i = 1
x = [a[0]]
y = []
while i < len(a):
	if a[i] > x[-1]:
		x.append(a[i])
		i += 1
	else:
		y.append(a[i])
		i += 1
y.reverse()
flag = True
for i in range(len(y) - 1):
	if y[i] <= y[i + 1]:
		print('NO')
		flag = False
		break
if flag == True:
	print('YES')
	print(len(x))
	print(*x)
	print(len(y))
	print(*y)


GI = lambda : int(input())
GIS = lambda : map(int, input().split())
LGIS = lambda : list(GIS())

def main():
	GI()
	ctr = [0] * (2 * 10 ** 5 + 1)
	for x in GIS():
		ctr[x] += 1
	inc = []
	dec = []
	for (i, c) in enumerate(ctr):
		if c == 0:
			continue
		if c > 2:
			print('NO')
			return
		inc.append(i)
		if c == 2:
			dec.append(i)
	dec.reverse()
	print('YES')
	for l in (inc, dec):
		print(len(l))
		print(' '.join(map(str, l)))
main()


n = int(input())
l = list(map(int, input().split()))
l.sort()
flag = True
count = [0] * (l[-1] + 1)
for i in l:
	count[i] += 1
	if count[i] == 3:
		flag = False
		break
else:
	ans_1 = []
	ans_2 = []
	for i in range(n):
		if i % 2 == 0:
			ans_1.append(l[i])
		else:
			ans_2.append(l[i])
	print('YES')
	print(len(ans_1))
	print(' '.join((str(i) for i in ans_1)))
	print(len(ans_2))
	ans_2.reverse()
	print(' '.join((str(i) for i in ans_2)))
if not flag:
	print('NO')


from sys import stdin as stdin
N = int(stdin.readline())
seq = list(map(int, stdin.readline().split()))
seq.sort()
inseq = [seq[0]]
deseq = []
ln = seq[0]
replastn = 1
curseq = 0
aborted = False
for i in range(1, len(seq)):
	cn = seq[i]
	if ln != cn:
		replastn = 1
	else:
		replastn += 1
		if replastn >= 3:
			aborted = True
			break
		curseq += curseq * -1 + (1 - curseq) * 1
	if curseq == 0:
		inseq.append(cn)
	else:
		deseq.append(cn)
	ln = cn
if aborted:
	print('NO')
else:
	deseq.reverse()
	print('YES')
	print(len(inseq))
	s = ''
	for l in inseq:
		s += str(l) + ' '
	print(s)
	print(len(deseq))
	s = ''
	for l in deseq:
		s += str(l) + ' '
	print(s)


n = int(input())
l = list(map(int, input().split()))
mask = [0] * 200001
l.sort()
f = []
s = []
for i in range(n):
	if not mask[l[i]]:
		f.append(l[i])
		mask[l[i]] = 1
	elif mask[l[i]] == 1:
		s.append(l[i])
		mask[l[i]] = 2
if len(f) + len(s) != n:
	print('NO')
else:
	print('YES')
	f.sort()
	s.sort(reverse=True)
	print(len(f))
	for i in range(len(f)):
		print(f[i], end=' ')
	print()
	print(len(s))
	for i in range(len(s)):
		print(s[i], end=' ')


def solve(array):
	elems = dict()
	for elem in array:
		if elem in elems and elems[elem] == 2:
			print('NO')
			return
		if elem not in elems:
			elems[elem] = 1
			continue
		elems[elem] += 1
	arr_1 = []
	arr_2 = []
	for key in elems:
		if elems[key] == 2:
			arr_1.append(key)
			arr_2.append(key)
		else:
			arr_2.append(key)
	arr_1 = sorted(arr_1)
	arr_2 = sorted(arr_2, reverse=True)
	print('YES')
	print(len(arr_1))
	print(' '.join(list(map(str, arr_1))))
	print(len(arr_2))
	print(' '.join(list(map(str, arr_2))))
arr_len = int(input())
array = list(map(int, input().split()))
solve(array)


from collections import *
n = int(input())
l = list(map(int, input().split()))
d = defaultdict(int)
for i in range(n):
	d[l[i]] += 1
x = list(d.keys())
y = list(d.values())
f = 0
for i in y:
	if i > 2:
		f = 1
		break
if f == 1:
	print('NO')
else:
	(ll, dd) = ([], [])
	for i in range(len(x)):
		if y[i] == 2:
			ll.append(x[i])
			dd.append(x[i])
		elif y[i] == 1:
			dd.append(x[i])
	print('YES')
	print(len(ll))
	ll.sort()
	print(*ll)
	dd.sort(reverse=True)
	print(len(dd))
	print(*dd)


n = int(input())
l = sorted(list(map(int, input().split())))
if n != 1:
	l1 = []
	l2 = []
	ok = True
	l1.append(l[0])
	for i in range(1, n):
		if l[i - 1] != l[i]:
			l1.append(l[i])
		else:
			l2.append(l[i])
	for i in range(1, len(l2)):
		if l2[i - 1] == l2[i]:
			ok = False
			break
	if not ok:
		print('NO')
	else:
		print('YES')
		print(len(l1))
		print(*l1)
		print(len(l2))
		print(*l2[::-1])
else:
	print('YES')
	print(1)
	print(*l)
	print(0)
	print()


from sys import stdin
input = stdin.readline
n = int(input())
l = sorted(list(map(int, input().split())))
(x1, x2) = ([], [])
for i in l:
	if len(x2) and len(x2) and (x1[-1] == i) and (x2[-1] == i):
		print('NO')
		exit()
	if len(x1) and x1[-1] == i:
		x2.append(i)
	else:
		x1.append(i)
x2 = x2[::-1]
print('YES')
print(len(x1))
print(*x1)
print(len(x2))
print(*x2)


from collections import defaultdict as dd
from collections import Counter as ccd
from itertools import permutations as pp
from itertools import combinations as cc
from random import randint as rd
from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq as hq
from math import gcd
mod = pow(10, 9) + 7

def inp(flag=0):
	if flag == 0:
		return list(map(int, input().strip().split(' ')))
	else:
		return int(input())
n = inp(1)
l = ccd(inp())
s1 = []
s2 = []
possible = True
for k in l:
	if l[k] > 2:
		possible = False
		break
	elif l[k] == 2:
		s1.append(k)
		s2.append(k)
	else:
		s1.append(k)
if possible:
	s1.sort()
	s2.sort(reverse=True)
	print('YES')
	print(len(s1))
	print(*s1)
	print(len(s2))
	print(*s2)
else:
	print('NO')


n = int(input())
In = input().split()
up = {}
down = {}
for i in range(n):
	tmp = int(In[i])
	if up.get(tmp):
		if down.get(tmp) and down[tmp]:
			print('NO')
			exit()
		if down.get(tmp):
			down[tmp] = 2
		else:
			down[tmp] = 1
	elif up.get(tmp):
		up[tmp] = 2
	else:
		up[tmp] = 1
print('YES')
print(len(up))
for i in sorted(up.keys()):
	print(i, end=' ')
print('\n', len(down), sep='')
reverseDown = []
for i in sorted(down.keys()):
	reverseDown.append(i)
reverseDown.reverse()
for i in reverseDown:
	print(i, end=' ')


n = int(input())
li = [int(x) for x in input().split()]
li.sort()
dic = {}
for i in range(n):
	val = li[i]
	if val in dic:
		if dic[val] == 2:
			print('NO')
			exit()
		else:
			dic[val] = dic[val] + 1
	else:
		dic.update({val: 1})
li1 = []
l1 = len(dic)
print('YES')
print(l1)
for key in dic:
	if dic[key] == 2:
		li1.append(key)
	print(key, end=' ')
count = len(li1)
print()
print(count)
if count == 0:
	print()
else:
	i = count - 1
	while i >= 0:
		print(li1[i], end=' ')
		i = i - 1


n = int(input())
A = [int(x) for x in input().split()]
count = dict()
ascending = []
descending = []
possible = True
for i in range(len(A)):
	count[A[i]] = count.get(A[i], 0) + 1
	if count[A[i]] > 2:
		print('NO')
		exit()
	elif count[A[i]] == 1:
		ascending.append(A[i])
	else:
		descending.append(A[i])
ascending.sort()
descending.sort(reverse=True)
print('YES')
print(len(ascending))
print(*ascending)
print(len(descending))
print(*descending)


import sys
from typing import List, Tuple, Dict
DEBUG = len(sys.argv) > 1 and sys.argv[1] == '-d'

def LOG(*argv):
	if DEBUG:
		print(*argv, file=sys.stderr)

def CHECK(cond, err_msg=''):
	if DEBUG:
		assert cond, err_msg

def CHECK_EQ(a, b, err_msg=''):
	CHECK(a == b, err_msg='{} v.s. {} {}'.format(a, b, err_msg))

def readval(typ=int):
	return typ(input())

def readvals(typ=int):
	return list(map(typ, input().split()))

def solve(n: int, arr: List[int]) -> str:
	(inc, dec) = ([], [])
	for i in range(n):
		can_put_in_inc = len(inc) == 0 or arr[inc[-1]] < arr[i]
		can_put_in_dec = len(dec) == 0 or arr[dec[-1]] > arr[i]
		if not can_put_in_inc and (not can_put_in_dec):
			return None
		elif can_put_in_inc and (not can_put_in_dec):
			inc.append(i)
		elif not can_put_in_inc and can_put_in_dec:
			dec.append(i)
		elif can_put_in_inc and can_put_in_dec:
			if i == n - 1:
				inc.append(i)
			elif arr[i + 1] > arr[i]:
				inc.append(i)
			else:
				dec.append(i)
	inc = set(inc)
	solution = ['0' if i in inc else '1' for i in range(n)]
	return ' '.join(solution)
CHECK_EQ(solve(9, [5, 1, 3, 6, 8, 2, 9, 0, 10]), '1 0 0 0 0 1 0 1 0')
CHECK_EQ(solve(5, [1, 2, 4, 0, 2]), None)
n = readval()
arr = readvals()
sol = solve(n, arr)
if sol is None:
	print('NO')
else:
	print('YES')
	print(sol)


n = int(input())
a = [int(t) for t in input().split(' ')]
a.sort()
s1 = []
s2 = []
s1 = [a[0]]
for ai in a[1:]:
	if ai == s1[-1]:
		if len(s2) and ai == s2[-1]:
			print('NO')
			exit()
		s2.append(ai)
	else:
		s1.append(ai)
print('YES')
print(len(s1))
print(*s1)
print(len(s2))
print(*reversed(s2))


import sys
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
str = 0
for i in range(1, n):
	if l[i] == l[i - 1]:
		str += 1
	if str > 1:
		print('NO')
		sys.exit(0)
	if l[i] != l[i - 1]:
		str = 0
occ = [0] * n
new = l[0]
occ[0] = 1
le = 1
for i in range(1, n):
	if l[i] > new:
		new = l[i]
		occ[i] = 1
		le += 1
print('YES')
print(le)
for i in range(n):
	if occ[i] == 1:
		print(l[i], end=' ')
print('')
print(n - le, end='\n')
if n - le == 0:
	print('')
for i in range(n):
	if occ[n - i - 1] == 0:
		print(l[n - i - 1], end=' ')


from collections import Counter
n = int(input())
arr = list(map(int, input().split()))
maxx = max(arr)
carr = [0] * (maxx + 1)
counter = 0
for i in range(n):
	carr[arr[i]] += 1
	if carr[arr[i]] > 2:
		counter = 1
		break
if counter == 1:
	print('NO')
else:
	print('YES')
	arr = []
	arr1 = []
	for i in range(maxx + 1):
		if carr[i] > 0:
			arr1.append(i)
			if carr[i] > 1:
				arr.append(i)
	arr = arr[::-1]
	print(len(arr1))
	print(*arr1)
	print(len(arr))
	print(*arr)


input()
lis2 = list(map(int, input().split()))
lis2.sort()
lis = []
str_dec = []
if len(lis2) > 0:
	str_dec.append(lis2[-1])
	lis2.pop()
for i in reversed(lis2):
	if i < str_dec[-1]:
		str_dec.append(i)
	else:
		lis.append(i)
dec = len(str_dec)
length_lis = len(lis)
val = 0
if len(lis) > 1:
	for i in reversed(range(1, length_lis)):
		if lis[i] >= lis[i - 1]:
			print('NO')
			val = 1
			break
if val == 0:
	print('YES')
	print(length_lis)
	for i in reversed(range(length_lis)):
		print(lis[i], end=' ')
	print()
	print(dec)
	for i in range(dec):
		print(str_dec[i], end=' ')
	print()


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict
import math
import heapq

def listIn():
	return list(map(int, stdin.readline().strip().split()))

def stringListIn():
	return [x for x in stdin.readline().split()]

def intIn():
	return int(stdin.readline())

def stringIn():
	return stdin.readline().strip()
n = intIn()
a = listIn()
a.sort()
di = {}
(li1, li2) = ([], [])
for ele in a:
	if ele not in di:
		di[ele] = 1
	else:
		di[ele] += 1
if max(di.values()) > 2:
	print('NO')
else:
	for ele in di:
		if di[ele] == 2:
			li1.append(ele)
			li2.append(ele)
		else:
			li1.append(ele)
	print('YES')
	print(len(li1))
	print(*sorted(li1))
	print(len(li2))
	li2 = sorted(li2)[::-1]
	print(*li2)


def solve(case):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in l:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	f = 0
	for i in d:
		if d[i] > 2:
			f = 1
	if f == 1:
		print('NO')
	else:
		print('YES')
		l.sort()
		l1 = []
		l2 = []
		for i in range(n):
			if i % 2 == 0:
				l1.append(l[i])
			else:
				l2.append(l[i])
		print(len(l1))
		print(*l1)
		l2.sort(reverse=True)
		print(len(l2))
		print(*l2)
solve(1)


n = int(input())
consult = {}
resp = True
nums = [int(x) for x in input().split(' ')]
nums.sort()
for k in nums:
	if k in consult:
		if consult[k] == 2:
			resp = False
			break
		else:
			consult[k] += 1
	else:
		consult[k] = 1
incr = [nums[0]]
decre = []
flag = 1
tam = len(nums)
for j in range(1, tam):
	if nums[j] == nums[j - 1]:
		flag = flag * -1
	if flag > 0:
		incr.append(nums[j])
	else:
		decre.append(nums[j])
tamanhoInc = len(incr)
tamanhoDecre = len(decre)
if resp:
	print('YES')
	print(len(incr))
	print(' '.join((str(k) for k in incr)))
	print(len(decre))
	print(' '.join((str(decre[k]) for k in range(tamanhoDecre - 1, -1, -1))))
else:
	print('NO')


def check(s):
	x = s
	s.sort()
	a = s[::2]
	b = s[1::2]
	for i in range(len(a) - 1):
		if a[i + 1] - a[i] == 0:
			print('NO')
			return 0
	for i in range(len(b) - 1):
		if b[i + 1] - b[i] == 0:
			print('NO')
			return 0
	print('YES')
	print(len(a))
	print(' '.join(map(str, a)))
	print(len(b))
	print(' '.join(map(str, b[::-1])))
n = int(input())
s = [int(i) for i in input().split()]
check(s)


R = lambda : map(int, input().split())
n = [*R()][0]
l = sorted([*R()])
(inc, dec) = (l[::2], [])
l = l[::-1]
if n & 1:
	l.pop(0)
dec = l[::2]
if len(set(inc)) + len(set(dec)) != n:
	print('NO')
else:
	print('YES')
	print(len(inc))
	print(*inc)
	print(len(dec))
	print(*dec)


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
l = dict(Counter(a))
m = []
f = 0
for (key, value) in l.items():
	if value >= 3:
		f = 1
		break
	elif value == 2:
		m.append(key)
m.sort(reverse=True)
a = list(set(a))
a.sort()
if f == 1:
	print('NO')
else:
	print('YES')
	print(len(a))
	print(*a)
	print(len(m))
	print(*m)


n = int(input())
A = list(map(int, input().split()))
A.sort()
B = []
C = []
for i in A:
	if len(B) == 0 or B[-1] != i:
		B.append(i)
	elif len(C) == 0 or C[-1] != i:
		C.append(i)
	else:
		print('NO')
		exit(0)
C.reverse()
print('YES')
print(len(B))
for i in B:
	if i != B[-1]:
		print(i, end=' ')
	else:
		print(i, end='')
print()
print(len(C))
for i in C:
	if i != C[-1]:
		print(i, end=' ')
	else:
		print(i, end='')
print()


n = int(input())
a = list(map(int, input().split()))
voz = []
yb = []
d = dict()
otp = []
import sys
for elem in a:
	if elem not in d:
		d[elem] = 1
	else:
		d[elem] += 1
for elem in d:
	if d[elem] > 2:
		print('NO')
		sys.exit()
	if d[elem] == 2:
		voz.append(elem)
yb = list(set(a) - set(voz))
print('YES')
print(len(voz))
print(*sorted(voz))
print(len(d))
print(*sorted(d.keys(), reverse=True))


n = int(input())
b = {}
for x in map(int, input().split()):
	if x in b:
		if b[x] == 2:
			print('NO')
			exit()
		else:
			b[x] += 1
	else:
		b[x] = 1
(a1, a2) = ([], [])
for x in b:
	a1.append(x)
	if b[x] == 2:
		a2.append(x)
print('YES')
print(len(a1))
print(*sorted(a1))
print(len(a2))
print(*sorted(a2)[::-1])


import sys
n = int(sys.stdin.readline())
check = [False] * n
arr = list(map(int, sys.stdin.readline().split()))
arr.sort()
ist = []
for i in range(n):
	if ist and ist[-1] < arr[i] or not ist:
		ist.append(arr[i])
		check[i] = True
dst = []
for i in range(n - 1, -1, -1):
	if not check[i]:
		if dst and dst[-1] > arr[i] or not dst:
			dst.append(arr[i])
			check[i] = True
if check == [True] * n:
	print('YES')
	print(len(ist))
	print(' '.join(map(str, ist)))
	print(len(dst))
	print(' '.join(map(str, dst)))
else:
	print('NO')


n = int(input())
s = list(map(int, str(input()).split()))
s = sorted(s)
inc = []
dec = []
no = False
for i in range(n):
	if i % 2 == 0:
		if i != 0 and s[i] == inc[-1]:
			print('NO')
			no = True
			exit(0)
		else:
			inc.append(s[i])
	elif i != 1 and s[i] == dec[-1]:
		print('NO')
		no = True
		exit(0)
	else:
		dec.append(s[i])
if no:
	pass
else:
	print('YES')
	print(len(inc))
	print(' '.join(map(str, inc)))
	print(len(dec))
	for i in range(len(dec)):
		print(dec[-i - 1], end=' ')


n = int(input())
a = [int(x) for x in input().split()]
mno = set()
stop = set()
b = []
c = []
for item in a:
	if item in mno and item not in stop:
		c.append(item)
		stop.add(item)
	elif item in stop:
		print('NO')
		break
	else:
		b.append(item)
		mno.add(item)
else:
	print('YES')
	print(len(b))
	print(*sorted(b))
	print(len(c))
	c.sort(reverse=True)
	print(*c)


n = int(input())
a = [int(x) for x in input().split()]
a.sort()
inc = []
dec = []
for i in range(n - 1):
	if a[i] == a[i + 1]:
		if len(dec) > 0 and dec[-1] == a[i]:
			print('NO')
			exit()
		dec += [a[i]]
	else:
		if len(inc) > 0 and inc[-1] == a[i]:
			print('NO')
			exit()
		inc += [a[i]]
inc += [a[-1]]
dec.sort(reverse=True)
print('YES')
print(len(inc))
print(*inc)
print(len(dec))
print(*dec)


input()
a = sorted(map(int, input().split()))
if any((x == y for (x, y) in zip(a, a[2:]))):
	print('NO')
	exit()
b = a[::2]
c = a[1::2]
print('YES', len(b), *b, len(c), *c[::-1])


n = int(input())
s = [int(x) for x in input().split()]
s.sort()
increase = []
increase_set = set()
decrease = []
decrease_set = set()
for i in s:
	if str(i) in increase_set:
		if str(i) in decrease_set:
			print('NO')
			exit()
		else:
			decrease.insert(0, str(i))
			decrease_set.add(str(i))
	else:
		increase.append(str(i))
		increase_set.add(str(i))
print('YES')
print(len(increase))
print(' '.join(increase))
print(len(decrease))
print(' '.join(decrease))


n = int(input())
a = list(map(int, input().split()))
a.sort()
incList = []
decList = []
temp = []
prev = -1
s = 0
for i in a:
	if prev != i:
		incList.append(i)
		s = 0
	else:
		temp.append(i)
		s += 1
	if s > 1:
		print('NO')
		exit(0)
	prev = i
for j in range(len(temp) - 1, -1, -1):
	decList.append(temp[j])
print('YES')
for i in (incList, decList):
	print(len(i))
	print(' '.join((str(j) for j in i)))


from sys import stdin
input = stdin.readline
n = int(input())
a = [int(x) for x in input().split()]
increasing = set()
decreasing = set()
for i in a:
	if i in increasing:
		if i in decreasing:
			print('NO')
			break
		else:
			decreasing.add(i)
	else:
		increasing.add(i)
else:
	increasing = list(increasing)
	decreasing = list(decreasing)
	increasing.sort()
	decreasing.sort(reverse=True)
	print('YES')
	print(len(increasing))
	print(*increasing)
	print(len(decreasing))
	print(*decreasing)


n = int(input())
arr = list(map(int, input().split()))
d = {}
(inc, dec) = ([], [])
flag = False
for i in arr:
	try:
		d[i] += 1
		if d[i] == 3:
			print('NO')
			flag = True
			break
	except:
		d[i] = 1
if flag:
	exit()
arr = sorted(arr)
inc.append(arr[0])
for i in range(1, n):
	if arr[i - 1] == arr[i]:
		dec.append(arr[i])
	else:
		inc.append(arr[i])
print('YES')
print(len(inc))
print(*inc)
print(len(dec))
print(*dec[::-1])


n = int(input())
a = list(map(int, input().split()))
a.sort()
c = 1
flag = 0
inc = []
dec = []
inc.append(a[0])
for x in range(1, len(a)):
	if x % 2 != 0:
		dec.append(a[x])
	else:
		inc.append(a[x])
	if a[x] == a[x - 1]:
		c += 1
	else:
		c = 0
		c += 1
	if c > 2:
		flag = 1
		break
if flag == 1:
	print('NO')
else:
	print('YES')
	print(len(inc))
	for x in inc:
		print(x, end=' ')
	print()
	print(len(dec))
	for x in range(len(dec) - 1, -1, -1):
		print(dec[x], end=' ')


inc = []
dec = []
n = int(input())
Arr = list(map(int, input().split()))
Arr.sort()
flag = True
inc = [Arr[0]]
count = 1
for i in range(1, n):
	if Arr[i] == Arr[i - 1]:
		count += 1
		if count == 3:
			print('No')
			flag = False
			break
		dec.append(Arr[i])
	else:
		count = 1
		inc.append(Arr[i])
if flag:
	print('Yes')
	print(len(inc))
	print(*inc)
	print(len(dec))
	print(*dec[::-1])


import sys
import copy
input = sys.stdin.readline
N = int(input())
a = sorted([int(x) for x in input().split()])
cnt = [0] * 200010
for x in a:
	cnt[x] += 1
for x in cnt:
	if x > 2:
		print('NO')
		exit()
asc = []
dsc = []
for (index, x) in enumerate(cnt):
	if x > 0:
		asc.append(index)
		cnt[index] -= 1
for (index, x) in enumerate(cnt):
	if x > 0:
		dsc.append(index)
asc.sort()
dsc.sort(reverse=True)
print('YES')
print(len(asc))
print(' '.join(map(str, asc)))
print(len(dsc))
print(' '.join(map(str, dsc)))


n = int(input())
a = [int(i) for i in input().split()]
a.sort()
inc = [a[0]]
dec = []
for i in range(1, n):
	if a[i - 1] != a[i]:
		inc.append(a[i])
	else:
		dec.append(a[i])
if len(dec) != len(set(dec)):
	print('NO')
else:
	print('YES')
	print(len(inc))
	for num in inc:
		print(num, end=' ')
	print()
	print(len(dec))
	for num in dec[::-1]:
		print(num, end=' ')
	print()


import sys

def ints():
	return list(map(int, sys.stdin.readline().strip().split()))
tc = 1
while tc:
	tc -= 1
	n = int(input())
	ls = ints()
	ans = 'YES'
	(op1, op2) = ([], [])
	s = [0 for _ in range(2 * 10 ** 5 + 1)]
	for i in ls:
		s[i] += 1
	for i in range(2 * 10 ** 5 + 1):
		if s[i] == 1:
			op1.append(i)
		elif s[i] == 2:
			op1.append(i)
			op2.append(i)
		elif s[i] > 2:
			ans = 'NO'
			break
	if ans == 'NO':
		print(ans)
	else:
		print(ans)
		print(len(op1))
		print(*op1)
		print(len(op2))
		print(*op2[::-1])


from sys import stdin, stdout
t = int(input())
l = list(map(int, stdin.readline().split()))
l.sort()
inc = []
dec = []
i = 0
while i < t:
	if i + 1 < t:
		if l[i] != l[i + 1]:
			inc.append(l[i])
			i += 1
		elif i + 2 < t:
			if l[i + 1] == l[i + 2]:
				print('NO')
				exit()
			else:
				inc.append(l[i])
				dec.append(l[i])
				i += 2
		else:
			inc.append(l[i])
			dec.append(l[i])
			i += 2
	else:
		inc.append(l[i])
		i += 1
dec.reverse()
print('YES')
print(len(inc))
if inc == []:
	print('')
else:
	for i in inc:
		stdout.write(str(i) + ' ')
	print()
print(len(dec))
if dec == []:
	print('')
else:
	for i in dec:
		stdout.write(str(i) + ' ')
	print()


def foo(arr):
	arr.sort()
	flag = True
	dic = {}
	for a in arr:
		if a in dic:
			if dic[a] + 1 > 2:
				flag = False
				break
			else:
				dic[a] += 1
		else:
			dic[a] = 1
	if flag is False:
		print('NO')
	else:
		inc = []
		incInd = []
		i = 0
		while i < len(arr) - 1:
			if arr[i] == arr[i + 1]:
				inc.append(arr[i])
				incInd.append(i)
				i = i + 2
			else:
				i += 1
		for a in incInd:
			arr[a] = -1
		arr.sort()
		print('YES')
		print(len(inc))
		print(' '.join((str(e) for e in inc)))
		while arr[0] == -1:
			arr.pop(0)
		print(len(arr))
		arr.reverse()
		print(' '.join((str(e) for e in arr)))
n = int(input())
arr = list(map(int, input().rstrip().split()))
foo(arr)


n = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
inc = []
dec = []
start = n - 1
if n % 2 == 1:
	start = n - 2
for i in range(0, n, 2):
	dec.append(a[i])
	if start > 0:
		inc.append(a[start])
	start -= 2
if sorted(list(set(inc))) == inc and sorted(list(set(dec)), reverse=True) == dec:
	print('YES')
	print(len(inc))
	print(*inc)
	print(len(dec))
	print(*dec)
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
a1 = set()
a2 = set()
for i in range(0, len(a)):
	if a[i] not in a1:
		a1.add(a[i])
	elif a[i] not in a2:
		a2.add(a[i])
	else:
		print('NO')
		exit()
print('YES')
print(len(a1))
print(*sorted(a1))
print(len(a2))
print(*sorted(a2, reverse=True))


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

def is_increasing_decreasing(nums):
	nums_dict = {}
	yes = 'Yes'
	no = 'No'
	for i in range(len(nums)):
		if nums[i] in nums_dict and nums_dict[nums[i]] == 2:
			return no
		elif nums[i] not in nums_dict:
			nums_dict[nums[i]] = 1
		else:
			nums_dict[nums[i]] += 1
	return (yes, nums_dict)

def run_and_print(yesno):
	yes = 'Yes'
	no = 'No'
	if is_increasing_decreasing(nums) == no:
		print(no)
		return
	elif yes in is_increasing_decreasing(nums):
		nums_incr_set = set(nums)
		nums_incr_lst = sorted(nums_incr_set)
		nums_dict = is_increasing_decreasing(nums)[1]
		new_nums = []
		for (key, value) in nums_dict.items():
			if key in nums_incr_set:
				value -= 1
			if value == 1:
				new_nums.append(key)
		nums_decr_lst = sorted(new_nums, reverse=True)
		print(yes)
		print(len(nums_incr_set))
		increasing = str(nums_incr_lst).replace(', ', ' ')
		increasing = increasing.strip('[')
		increasing = increasing.strip(']')
		print(increasing)
		print(len(nums_decr_lst))
		decreasing = str(nums_decr_lst).replace(', ', ' ')
		decreasing = decreasing.strip('[')
		decreasing = decreasing.strip(']')
		print(decreasing)
yesno = is_increasing_decreasing(nums)
run_and_print(yesno)


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
from collections import *
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	new_number = 0
	while number > 0:
		new_number += number % base
		number //= base
	return new_number

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True

def main():
	n = ii()
	arr = li()
	c = Counter(arr)
	i = []
	d = []
	for key in list(c.keys()):
		if c[key] > 2:
			print('NO')
			exit()
		elif c[key] == 2:
			i.append(key)
			d.append(key)
		else:
			i.append(key)
	i = sorted(i)
	d = sorted(d, reverse=True)
	print('YES')
	print(len(i))
	print(*i)
	print(len(d))
	print(*d)
main()


from collections import defaultdict as dd
import math

def nn():
	return int(input())

def li():
	return list(input())

def mi():
	return map(int, input().split())

def lm():
	return list(map(int, input().split()))

def getanswers():
	n = nn()
	seq = lm()
	lower = None
	upper = None
	answers = []
	for i in range(n - 1):
		if seq[i + 1] > seq[i]:
			if lower == None or seq[i] > lower:
				lower = seq[i]
				answers.append(0)
			elif upper == None or seq[i] < upper:
				upper = seq[i]
				answers.append(1)
			else:
				print('No')
				return
		if seq[i + 1] <= seq[i]:
			if upper == None or seq[i] < upper:
				upper = seq[i]
				answers.append(1)
			elif upper == None or seq[i] > lower:
				lower = seq[i]
				answers.append(0)
			else:
				print('No')
				return
	i = n - 1
	if upper == None or seq[i] < upper:
		upper = seq[i]
		answers.append(1)
	elif lower == None or seq[i] > lower:
		lower = seq[i]
		answers.append(0)
	else:
		print('No')
		return
	print('Yes')
	print(*answers)
	return
getanswers()


(n, a) = (int(input()), sorted(list(map(int, input().split()))))
not_ok = any((a[i + 2] == a[i + 1] == a[i] for i in range(n - 2)))
if not_ok:
	print('NO')
else:
	print('YES')
	(x, y) = ([a[0]], [])
	for i in range(n - 1):
		(y if a[i + 1] == a[i] else x).append(a[i + 1])
	print(len(x))
	print(*x)
	print(len(y))
	print(*y[::-1])


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	d = {}
	for i in range(n):
		t = d.get(a[i], 0) + 1
		if t >= 3:
			print('NO')
			return
		d[a[i]] = t
	up = []
	down = []
	for k in d:
		if d[k] == 2:
			up.append(k)
			down.append(k)
		else:
			up.append(k)
	print('YES')
	print(len(up))
	print(*up)
	print(len(down))
	print(*down[::-1])
main()


n = int(input())
a = list(map(int, input().split()))
a.sort()
vosr = [a[0]]
ub = []
for i in range(1, n):
	if a[i] != a[i - 1]:
		vosr.append(a[i])
	else:
		ub.append(a[i])
ub.reverse()
ist = True
for i in range(1, len(ub)):
	if ub[i] == ub[i - 1]:
		ist = False
		break
if not ist:
	print('NO')
else:
	print('YES')
	print(len(vosr))
	print(*vosr)
	print(len(ub))
	print(*ub)


n = int(input())
a = [int(i) for i in input().split()]
(left, right) = (set(), set())
for ai in a:
	if ai not in left:
		left.add(ai)
	else:
		right.add(ai)
if len(left) + len(right) != n:
	print('NO')
else:
	print('YES')
	left = [str(i) for i in sorted(list(left))]
	right = [str(i) for i in sorted(list(right), reverse=True)]
	print(len(left))
	print(' '.join(left))
	print(len(right))
	print(' '.join(right))


n = int(input())
lst = list(map(int, input().split()))
lst.sort()
(ans1, ans2) = ([], [])
N = [0] * (2 * 10 ** 5 + 1)
for i in range(n):
	N[lst[i]] += 1
	if N[lst[i]] == 1:
		ans1.append(lst[i])
	elif N[lst[i]] == 2:
		ans2.append(lst[i])
	else:
		print('NO')
		exit()
ans1.reverse()
print('YES')
print(len(ans2))
print(*ans2)
print(len(ans1))
print(*ans1)


n = int(input())
l = list(map(int, input().split(' ')))
l.sort()
(inc, dc, k) = ([l[0]], [], 1)
for i in range(1, n):
	if l[i] > inc[-1]:
		inc.append(l[i])
	else:
		dc.append(l[i])
dc.sort(reverse=True)
for i in range(1, len(dc)):
	if dc[i] >= dc[i - 1]:
		k = 0
		break
if k == 0:
	print('NO')
else:
	print('YES')
	print(len(inc))
	print(' '.join(list(map(str, inc))))
	print(len(dc))
	print(' '.join(list(map(str, dc))))


import sys
input()
arrayS = input().split()
array = list()
for i in arrayS:
	array.append(int(i))
array.sort()
inc = list()
dec = list()
inc.append(array[0])
flag = False
for i in range(1, len(array)):
	if array[i] > array[i - 1]:
		flag = False
		inc.append(array[i])
	elif not flag:
		dec.append(array[i])
		flag = True
	else:
		print('NO')
		sys.exit()
print('YES')
print(len(inc))
print(' '.join(map(str, inc)))
print(len(dec))
if len(dec) > 0:
	dec.reverse()
	print(' '.join(map(str, dec)))
else:
	print()


import collections
b = True
a = int(input())
ln = list(map(int, input().split()))
c = collections.Counter(ln)
for i in c:
	if c[i] > 2:
		b = False
if b:
	s1 = []
	s2 = []
	for i in c:
		if c[i] == 1:
			s1.append(i)
		else:
			s1.append(i)
			s2.append(i)
	s1.sort()
	s2.sort(reverse=True)
	print('Yes')
	print(len(s1))
	if len(s1) > 0:
		print(' '.join(map(str, s1)))
	else:
		print('\n')
	print(len(s2))
	if len(s2) > 0:
		print(' '.join(map(str, s2)))
	else:
		print('\n')
else:
	print('NO')


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

def TwoShuffled(n, arr):
	from collections import Counter as ct
	act = ct(arr)
	maxcount = max(act.values())
	incarr = []
	decarr = []
	if maxcount > 2:
		return 'NO'
	else:
		print('YES')
		if maxcount == 1:
			print(n)
			incstr = ' '.join((str(el) for el in arr))
			print(incstr)
			print(0)
			return ''
		else:
			for i in act:
				incarr.append(i)
				if act[i] == 2:
					decarr.append(i)
			decarr = sorted(decarr, reverse=True)
			incstr = ' '.join((str(el) for el in incarr))
			decstr = ' '.join((str(el) for el in decarr))
			print(len(incarr))
			print(incstr)
			print(len(decarr))
			return decstr
print(TwoShuffled(n, arr))


n = int(input())
a = [int(x) for x in input().split()]
p = [0] * (2 * 100005)
for i in a:
	p[i] += 1
ans = True
for i in p:
	if i > 2:
		ans = False
a.sort()
t = []
r = []
for i in sorted(set(a), reverse=True):
	if p[i] == 2:
		t.append(i)
		r.append(i)
	else:
		t.append(i)
if ans:
	print('YES')
	print(len(t))
	print(*sorted(t))
	print(len(r))
	print(*r)
else:
	print('NO')


import sys
n = int(input())
arr = list(map(int, input().split()))
dct = {}
for i in arr:
	if i in dct:
		dct[i] += 1
	else:
		dct[i] = 1
inc = []
dec = []
for k in dct.keys():
	if dct[k] > 2:
		print('No')
		sys.exit()
	elif dct[k] == 2:
		inc += [k]
		dec += [k]
	else:
		inc += [k]
inc = sorted(inc)
dec = sorted(dec, reverse=True)
print('YES')
print(len(inc))
print(' '.join(map(str, inc)))
print(len(dec))
print(' '.join(map(str, dec)))


import bisect
import decimal
from decimal import Decimal
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
mod = 10 ** 9 + 7
decimal.getcontext().prec = 46

def primeFactors(n):
	prime = set()
	while n % 2 == 0:
		prime.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.add(i)
			n = n // i
	if n > 2:
		prime.add(n)
	return list(prime)

def getFactors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return factors

def modefiedSieve():
	mx = 10 ** 7 + 1
	sieve = [-1] * mx
	for i in range(2, mx):
		if sieve[i] == -1:
			sieve[i] = i
			for j in range(i * i, mx, i):
				if sieve[j] == -1:
					sieve[j] = i
	return sieve

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	num = []
	for p in range(2, n + 1):
		if prime[p]:
			num.append(p)
	return num

def lcm(a, b):
	return a * b // math.gcd(a, b)

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]), reverse=True)

def list_input():
	return list(map(int, input().split()))

def num_input():
	return map(int, input().split())

def string_list():
	return list(input())

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binaryToDecimal(n):
	return int(n, 2)

def DFS(n, s, adj):
	visited = [False for i in range(n + 1)]
	stack = []
	stack.append(s)
	while len(stack):
		s = stack[-1]
		stack.pop()
		if not visited[s]:
			visited[s] = True
		for node in adj[s]:
			if not visited[node]:
				stack.append(node)

def maxSubArraySum(a, size):
	max_so_far = -sys.maxsize - 1
	max_ending_here = 0
	start = 0
	end = 0
	s = 0
	for i in range(0, size):
		max_ending_here += a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
			start = s
			end = i
		if max_ending_here < 0:
			max_ending_here = 0
			s = i + 1
	return (max_so_far, start, end)

def lis(arr):
	n = len(arr)
	lis = [1] * n
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] >= arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
	maximum = 0
	for i in range(n):
		maximum = max(maximum, lis[i])
	return maximum

def solve():
	n = int(input())
	arr = list_input()
	arr.sort()
	(increasing, decreasing) = ([], [])
	for i in range(0, n, 2):
		if increasing == []:
			increasing.append(arr[i])
			continue
		if increasing[-1] == arr[i]:
			print('NO')
			return
		increasing.append(arr[i])
	if n % 2 == 0:
		i = n - 1
	else:
		i = n - 2
	while i >= 0:
		if decreasing == []:
			decreasing.append(arr[i])
		else:
			if decreasing[-1] == arr[i]:
				print('NO')
				return
			decreasing.append(arr[i])
		i -= 2
	print('YES')
	print(len(increasing))
	print(*increasing)
	print(len(decreasing))
	print(*decreasing)
t = 1
for _ in range(t):
	solve()


from collections import *
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
for i in range(len(a)):
	if c[a[i]] > 2:
		print('NO')
		exit(0)
a.sort(reverse=True)
b = []
c = []
for i in range(n):
	if len(b) == 0 or b[-1] != a[i]:
		b.append(a[i])
	else:
		c.append(a[i])
b = b[::-1]
print('YES')
print(len(b))
print(*b)
print(len(c))
print(*c)


import atexit
import io
import sys
_I_B = sys.stdin.read().splitlines()
input = iter(_I_B).__next__
_O_B = io.StringIO()
sys.stdout = _O_B

@atexit.register
def write():
	sys.__stdout__.write(_O_B.getvalue())
n = int(input())
a = list(map(int, input().split()))
d = dict()
si = []
sd = []
for i in a:
	try:
		d[i] += 1
		if d[i] > 2:
			print('NO')
			exit(0)
		if d[i] == 2:
			sd.append(i)
	except KeyError:
		d[i] = 1
		si.append(i)
si.sort()
sd.sort(reverse=True)
print('YES')
print(len(si))
for i in si:
	print(i, end=' ')
print()
print(len(sd))
for i in sd:
	print(i, end=' ')
print()


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')
		exit()
inc = list(inc)
dec = list(dec)
inc.sort(reverse=True)
dec.sort()
print('YES')
print(len(dec))
print(*dec)
print(len(inc))
print(*inc)


n = int(input())
l = sorted(list(map(int, input().split())))
increase = [-1]
ic = 0
decrease = [-1]
dc = 0
for i in range(n):
	if l[i] > increase[ic]:
		ic += 1
		increase.append(l[i])
	elif l[i] > decrease[dc]:
		dc += 1
		decrease.append(l[i])
	else:
		print('NO')
		exit()
increase.remove(-1)
decrease.remove(-1)
print('YES')
print(ic)
if ic > 0:
	print(' '.join(map(str, increase)))
else:
	print('')
print(dc)
if dc > 0:
	print(' '.join(map(str, decrease[::-1])))
else:
	print('')


n = int(input())
v = {}
(f, l) = ([], [])
for i in sorted(map(int, input().split())):
	if v.get(i, 0):
		l.append(i)
		v[i] += 1
	else:
		f.append(i)
		v[i] = 1
	if v[i] == 3:
		exit(print('NO'))
print('YES')
print(len(f))
print(*f)
print(len(l))
print(*l[::-1])


from collections import defaultdict
import sys
n = int(input())
l = list([int(x) for x in input().split()])
il = []
dl = []
count = defaultdict(int)
for i in range(n):
	if count[l[i]] == 2:
		print('NO')
		sys.exit()
	elif count[l[i]] == 0:
		il.append(l[i])
	elif count[l[i]] == 1:
		dl.append(l[i])
	count[l[i]] += 1
il.sort()
dl.sort(reverse=True)
print('YES')
print(len(il))
print(*il)
print(len(dl))
print(*dl)


n = int(input())
arr = list(map(int, input().split()))
counter = dict()
for i in arr:
	if i in counter:
		counter[i] += 1
	else:
		counter[i] = 1
if any((j for j in counter.values() if j > 2)):
	print('NO')
else:
	arr1 = [i for i in counter]
	arr2 = [i for i in counter if counter[i] > 1]
	arr1.sort()
	arr2 = sorted(arr2, reverse=True)
	print('YES')
	print(len(arr1))
	print(*arr1)
	print(len(arr2))
	print(*arr2)


n = int(input())
a = list(map(int, input().split()))
if n == 1:
	print('YES')
	print('1')
	print(a[0])
	print('0')
	print()
else:
	a.sort()
	t = 1
	b = [a[0]]
	c = []
	for i in range(1, n):
		if b[-1] < a[i]:
			b.append(a[i])
		else:
			c.append(a[i])
	for j in range(len(c) - 1):
		if c[j] < c[j + 1]:
			continue
		else:
			print('NO')
			t = 0
			break
	if t == 1:
		print('YES')
		print(len(b))
		print(*b)
		print(len(c))
		print(*c[::-1])


num = int(input().strip())
numbers = [int(i) for i in input().strip().split()]
num_dict = dict()
impossible = False
for i in numbers:
	if i not in num_dict:
		num_dict[i] = 1
	else:
		num_dict[i] += 1
	if num_dict[i] > 2:
		impossible = True
		break
if impossible:
	print('No')
else:
	array1 = []
	array2 = []
	for i in num_dict:
		if num_dict[i] - 1 > 0:
			array1.append(i)
			array2.append(i)
			num_dict[i] -= 2
		elif num_dict[i] - 1 == 0:
			array2.append(i)
			num_dict[i] -= 1
	array1.sort()
	array2.sort(reverse=True)
	print('yes')
	print(len(array1))
	print(' '.join([str(i) for i in array1]))
	print(len(array2))
	print(' '.join([str(i) for i in array2]))


n = int(input())
sequence = list(map(int, input().split()))
sequence.sort()
temp = []
test = 0
y = [sequence[0]]
count = 1
for i in range(1, n):
	if sequence[i] == sequence[i - 1]:
		count = count + 1
		if count == 3:
			test = 1
		temp.append(sequence[i])
	else:
		count = 1
		y.append(sequence[i])
if test != 0:
	print('NO')
else:
	print('YES')
	print(len(y))
	print(*y)
	print(len(temp))
	print(*temp[::-1])


n = int(input())
a = list(map(int, input().split()))
count = {}
for i in a:
	count[i] = count.get(i, 0) + 1
ispos = True
for k in count:
	if count[k] > 2:
		ispos = False
if ispos == False:
	print('NO')
else:
	print('YES')
	(s1, s2) = ([], [])
	for k in count:
		if count[k] == 2:
			s1.append(k)
			s2.append(k)
		else:
			s1.append(k)
	s1.sort()
	s2.sort(reverse=True)
	print(len(s1))
	for i in s1:
		print(i, end=' ')
	print()
	print(len(s2))
	for i in s2:
		print(i, end=' ')
	print()


n = int(input())
array = list(map(int, input().split()))
array.sort()
i = 0
first = []
second = []
while i < n:
	n1 = array[i]
	first.append(n1)
	i += 1
	if i == n:
		break
	n2 = array[i]
	second.append(n2)
	i += 1
	if i == n:
		break
	if n1 == n2 and n2 == array[i]:
		print('No')
		exit(0)
print('Yes')
print(len(first))
print(' '.join([str(i) for i in first]))
print(len(second))
print(' '.join([str(i) for i in reversed(second)]))


n = int(input())
a = [int(x) for x in input().split()]
a.sort()
cnt = [0] * 200005
flag = 0
for i in a:
	cnt[i] += 1
(inc, dec) = ([], [])
a = list(set(a))
for i in a:
	if cnt[i] >= 1:
		inc.append(i)
	if cnt[i] == 2:
		dec.append(i)
	elif cnt[i] > 2:
		flag = 1
		break
if flag:
	print('NO')
else:
	print('YES')
	print(len(inc))
	print(*inc)
	print(len(dec))
	print(*dec[::-1])


n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
b = []
c = []
k = 1
d = 0
for i in range(1, n):
	if a[i] - a[i - 1] == 0:
		b.append(a[i])
		k += 1
	else:
		c.append(a[i])
		k = 1
	if k > 2:
		print('NO')
		d = 1
		break
c.append(a[0])
if d == 0:
	print('YES')
	print(len(b))
	print(*sorted(b))
	print(len(c))
	c = sorted(c)
	f = [0] * len(c)
	for i in range(len(c)):
		f[len(c) - i - 1] = c[i]
	print(*f)


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

def doub(key):
	if count[key] == 2:
		doubled.append(key)
	return
if max(count.values()) <= 2:
	doubled = []
	irr = list(map(doub, count.keys()))
	desc = list(map(str, sorted(doubled, reverse=True)))
	asc = list(map(str, sorted(count.keys())))
	print('YES')
	print(len(asc))
	print(' '.join(asc))
	print(len(desc))
	print(' '.join(desc))
else:
	print('NO')


import sys
input = sys.stdin.readline
n = int(input())
l = list(map(int, input().split()))
dic = {}
inc = list()
dec = list()
for i in l:
	if i not in dic:
		dic[i] = 1
	else:
		dic[i] += 1
if 3 <= max(dic.values()):
	print('NO')
else:
	for i in list(sorted(dic.keys())):
		if dic[i] == 2:
			dec.append(i)
		inc.append(i)
	print('YES')
	print(len(inc))
	if inc == []:
		print()
	else:
		[print(i, end=' ') for i in inc]
		print()
	print(len(dec))
	if dec == []:
		print()
	else:
		[print(i, end=' ') for i in dec[::-1]]
		print()


n = int(input())
a = list(map(int, input().split()))
d = dict()
si = []
sd = []
for i in a:
	try:
		d[i] += 1
		if d[i] > 2:
			print('NO')
			exit(0)
		if d[i] == 2:
			sd.append(i)
	except KeyError:
		d[i] = 1
		si.append(i)
si.sort()
sd.sort(reverse=True)
print('YES')
print(len(si))
for i in si:
	print(i, end=' ')
print()
print(len(sd))
for i in sd:
	print(i, end=' ')
print()


n = int(input())
a = [int(x) for x in input().split()]
a.sort()
prev = -1
(x, y) = ([], [])
for i in range(len(a)):
	if a[i] != prev:
		x.append(a[i])
	else:
		y.append(a[i])
	prev = a[i]
ok = True
for i in range(len(x) - 1):
	if x[i] == x[i + 1]:
		ok = False
for i in range(len(y) - 1):
	if y[i] == y[i + 1]:
		ok = False
if ok == False:
	print('NO')
else:
	print('YES')
	print(len(x))
	for i in x:
		print(i, end=' ')
	print()
	print(len(y))
	for i in y[::-1]:
		print(i, end=' ')


import collections
n = int(input())
a = sorted(list(map(int, input().strip().split())))
x = []
y = []
d = collections.Counter(a)
for item in d:
	if d[item] > 2:
		print('NO')
		break
	elif d[item] == 2:
		x.append(item)
		y.append(item)
	else:
		x.append(item)
else:
	x.sort()
	y.sort(reverse=True)
	print('YES')
	print(len(x))
	print(*x)
	print(len(y))
	print(*y)


n = int(input())
a = list(map(int, input().split()))
inc = [-1]
dec = [1000000000.0]
ans = [0] * (n + 1)
for i in range(n):
	if a[i] > inc[-1] and a[i] < dec[-1]:
		if i == n - 1:
			inc.append(a[i])
		else:
			y = a[i + 1]
			if a[i] < y:
				inc.append(a[i])
			else:
				dec.append(a[i])
				ans[i] = 1
	elif a[i] > inc[-1] and a[i] >= dec[-1]:
		inc.append(a[i])
	elif a[i] <= inc[-1] and a[i] < dec[-1]:
		dec.append(a[i])
		ans[i] = 1
	elif a[i] <= inc[-1] and a[i] >= dec[-1]:
		print('NO')
		exit(0)
print('YES')
print(*ans[0:n])


import math
import collections
import bisect

def cint():
	return list(map(int, input().split()))

def cstr():
	return list(map(str, input().split(' ')))

def solve():
	n = int(input())
	lst = cint()
	lst.sort()
	first_lst = []
	second_lst = []
	for i in range(len(lst)):
		if i == 0:
			first_lst.append(lst[i])
		elif lst[i] == first_lst[-1]:
			if len(second_lst) == 0:
				second_lst.append(lst[i])
			elif lst[i] == second_lst[-1]:
				print('NO')
				return
			else:
				second_lst.append(lst[i])
		else:
			first_lst.append(lst[i])
	second_lst.reverse()
	print('YES')
	print(len(first_lst))
	for i in first_lst:
		print(i, end=' ')
	print('')
	print(len(second_lst))
	for i in second_lst:
		print(i, end=' ')
	print('')
t = 1
while t != 0:
	solve()
	t -= 1


import sys
from functools import reduce
from collections import defaultdict

def shuffled_sequence(ss):
	if len(ss) == 0:
		return 'NO'
	sss = sorted(ss)
	ssi = []
	ssi_d = []
	ssd = []
	ssd_d = []
	ssi.append(sss[0])
	ssd.append(sss[-1])
	for s in sss[1:]:
		if s > ssi[-1]:
			ssi.append(s)
		else:
			ssi_d.append(s)
	for s in list(reversed(sss))[1:]:
		if s < ssd[-1]:
			ssd.append(s)
		else:
			ssd_d.append(s)
	if len(set(ssi_d)) == len(ssi_d):
		print('YES')
		if len(ssi_d) == 0 or len(ssi_d) == 1:
			if len(ssi_d) == 0:
				print(0)
				print('')
			else:
				print(1)
				print(ssi_d[0])
		else:
			print(len(ssi_d))
			for s in ssi_d:
				print(s, end=' ')
			print('')
		print(len(ssi))
		for s in ssi[::-1]:
			print(s, end=' ')
		print('')
	elif len(set(ssd_d)) == len(ssd_d):
		print('YES')
		if len(ssd_d) == 0 or len(ssd_d) == 1:
			if len(ssd_d) == 0:
				print(0)
				print('')
			else:
				print(1)
				print(ssd_d[0])
		else:
			print(len(ssd_d))
			for s in ssd_d:
				print(s, end=' ')
			print('')
		print(len(ssd))
		for s in ssd[::-1]:
			print(s, end=' ')
		print('')
	else:
		print('NO')

def io():
	totalIns = int(sys.stdin.readline(), 10)
	ss = [] * totalIns
	for i in sys.stdin.readline().strip().split():
		ss.append(int(i, 10))
	shuffled_sequence(ss)
io()


num = int(input())
array = sorted(list(map(int, input().split())))
a = []
d = []
counter = 1
for x in range(len(array) - 1):
	if counter == 3:
		print('NO')
		break
	elif array[x] == array[x + 1]:
		counter += 1
		d.append(array[x])
	else:
		counter = 1
		a.append(array[x])
else:
	a.append(array[-1])
	a.sort()
	d.sort(reverse=True)
	print('YES')
	print(len(a))
	print(*a)
	print(len(d))
	print(*d)


from collections import Counter
n = int(input())
arr = list(map(int, input().split()))
a = sorted(arr)
b = a.copy()
if len(set(arr)) == len(arr):
	print('YES')
	print(0)
	print()
	print(len(arr))
	print(*a[::-1], sep=' ')
else:
	p = Counter(a)
	flag = 0
	u = []
	d = []
	for (i, j) in zip(p.keys(), p.values()):
		if j > 2:
			flag = 1
			break
		elif j == 1:
			u.append(i)
		else:
			u.append(i)
			d.append(i)
	if flag == 1:
		print('NO')
	else:
		print('YES')
		print(len(u))
		print(*u, sep=' ')
		print(len(d))
		print(*d[::-1], sep=' ')


def posled_cf():
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	from collections import Counter
	c = Counter()
	for i in l:
		c[i] += 1
		if c[i] > 2:
			return 'NO'
	a = []
	b = []
	t = True
	for i in l:
		if c[i] == 2:
			if t:
				a.append(i)
				t = False
			else:
				b.append(i)
				t = True
		else:
			a.append(i)
	print('YES')
	print(len(a))
	print(*a)
	print(len(b))
	print(*reversed(b))
	exit()
print(posled_cf())


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()
from collections import Counter
n = int(input())
a = sorted(list(map(int, input().split())))
c = Counter(a)
for i in a:
	if c[i] > 2:
		print('NO')
		exit()
print('YES')
print(len(a[::2]))
print(*a[::2])
if len(a) % 2 != 0:
	print(len(a[len(a) - 2:0:-2]))
	print(*a[len(a) - 2:0:-2])
else:
	print(len(a[:0:-2]))
	print(*a[:0:-2])


n = int(input())
l = [int(x) for x in input().split()]
l = sorted(l)
length = len(l)
(a1, a2) = ([l[0]], [])
flag = 0
for i in range(1, length):
	if i >= 2 and l[i] == l[i - 1] == l[i - 2]:
		print('No')
		flag = 1
		break
	elif l[i] == l[i - 1]:
		a2.append(l[i])
	else:
		a1.append(l[i])
a2.reverse()
if flag == 0:
	print('YES')
	print(len(a1))
	print(*a1)
	print(len(a2))
	print(*a2)


s = input()
l = list(map(int, input().split()))
l.sort()
d = dict()
first = []
second = []
flag = 0
for t in l:
	if t not in d:
		d[t] = 1
		first += [t]
	else:
		d[t] += 1
		if d[t] > 2:
			flag = 1
			break
		else:
			second += [t]
if flag == 1:
	print('NO')
else:
	print('YES')
	print(len(first))
	for h in first:
		print(h, end=' ')
	print()
	second.sort(reverse=True)
	print(len(second))
	for h in second:
		print(h, end=' ')
	print()


n = int(input())
s = list(map(int, input().split()))
a = {}
s.sort()
s.reverse()
for i in s:
	a[i] = 0
flag = 1
for i in s:
	a[i] += 1
	if a[i] > 2:
		flag = 0
if flag == 0:
	print('NO')
else:
	print('YES')
	cnt = 0
	ans1 = []
	ans2 = []
	for i in a.keys():
		if a[i] == 2:
			cnt += 1
			ans1.append(i)
		ans2.append(i)
	ans1.reverse()
	print(cnt)
	for i in range(0, cnt):
		print(ans1[i], end=' ')
	print()
	print(n - cnt)
	for i in range(0, n - cnt):
		print(ans2[i], end=' ')
	print()


from collections import *
from math import *
from itertools import *

def I():
	return map(int, input().strip().split())
n = int(input())
arr = list(I())
cont = False
frq = defaultdict(int)
for i in arr:
	frq[i] += 1
	cont = cont or frq[i] >= 3
if cont:
	print('NO')
else:
	arr.sort()
	(a, b) = ([], [])
	for i in frq.keys():
		if frq[i] > 1:
			a.append(i)
			b.append(i)
		else:
			b.append(i)
	a.sort()
	b.sort()
	b.reverse()
	print('YES')
	print(len(a))
	print(*a)
	print(len(b))
	print(*b)


from math import sqrt, ceil, floor
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
import string

def c(s, f):
	for i in range(len(s) - 1):
		if s[i + 1] <= s[i]:
			stdout.write('NO')
			return
	for i in range(len(f) - 1):
		if f[i + 1] <= f[i]:
			stdout.write('NO')
			return
	stdout.write('YES\n%d\n' % len(f))
	for i in f:
		stdout.write('%d ' % i)
	stdout.write('\n%d\n' % len(s))
	for i in reversed(range(len(s))):
		stdout.write('%d ' % s[i])
n = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
a.sort()
f = [a[0]]
s = []
for i in range(n - 1):
	if a[i + 1] == a[i]:
		s.append(a[i + 1])
	else:
		f.append(a[i + 1])
c(s, f)