Vitaly has an array of n distinct integers. Vitaly wants to divide this array into three non-empty sets so as the following conditions hold: 

  The product of all numbers in the first set is less than zero ( < 0).  The product of all numbers in the second set is greater than zero ( > 0).  The product of all numbers in the third set is equal to zero.  Each number from the initial array must occur in exactly one set. 

Help Vitaly. Divide the given array.


-----Input-----

The first line of the input contains integer n (3 ≤ n ≤ 100). The second line contains n space-separated distinct integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 10^3) — the array elements.


-----Output-----

In the first line print integer n_1 (n_1 > 0) — the number of elements in the first set. Then print n_1 numbers — the elements that got to the first set.

In the next line print integer n_2 (n_2 > 0) — the number of elements in the second set. Then print n_2 numbers — the elements that got to the second set.

In the next line print integer n_3 (n_3 > 0) — the number of elements in the third set. Then print n_3 numbers — the elements that got to the third set.

The printed sets must meet the described conditions. It is guaranteed that the solution exists. If there are several solutions, you are allowed to print any of them.


-----Examples-----
Input
3
-1 2 0

Output
1 -1
1 2
1 0

Input
4
-1 -2 -3 0

Output
1 -1
2 -3 -2
1 0

Source: codeforces | Difficulty: EASY
Tags: Complete search

Implementation

Constructive algorithms


Solutions:
n = int(input())
l = list(map(int, input().split()))
(a, b, c) = ([], [], [])
for i in l:
	if i < 0:
		a.append(i)
	elif i > 0:
		b.append(i)
	else:
		c.append(i)
if not b:
	b.append(a.pop())
	b.append(a.pop())
if len(a) % 2 == 0:
	c.append(a.pop())
print(len(a), *a)
print(len(b), *b)
print(len(c), *c)


n = int(input())
mat = map(int, input().split())
(a, b, c) = ([], [], [])
for i in mat:
	if i < 0:
		a.append(i)
	elif i > 0:
		b.append(i)
	else:
		c.append(i)
if len(b) == 0:
	b.append(a.pop())
	b.append(a.pop())
if len(a) % 2 == 0:
	c.append(a.pop())
print(len(a), *a, sep=' ')
print(len(b), *b, sep=' ')
print(len(c), *c, sep=' ')


n = int(input())
a = [int(x) for x in input().split()]
b = []
c = []
d = []
d.append(0)
a.remove(0)
for i in range(n - 1):
	if a[i] < 0:
		b.append(a[i])
	else:
		c.append(a[i])
if len(c) == 0 and len(b) % 2 != 0:
	c.append(b[-1])
	b.remove(b[-1])
	c.append(b[-1])
	b.remove(b[-1])
	print(len(b), end=' ')
	for i in b:
		print(i, end=' ')
	print(' ')
	print(len(c), end=' ')
	for i in c:
		print(i, end=' ')
	print(' ')
	print(len(d), end=' ')
	for i in d:
		print(i, end=' ')
elif len(c) == 0 and len(b) % 2 == 0:
	d.append(b[-1])
	b.remove(b[-1])
	c.append(b[-1])
	b.remove(b[-1])
	c.append(b[-1])
	b.remove(b[-1])
	print(len(b), end=' ')
	for i in b:
		print(i, end=' ')
	print(' ')
	print(len(c), end=' ')
	for i in c:
		print(i, end=' ')
	print(' ')
	print(len(d), end=' ')
	for i in d:
		print(i, end=' ')
elif len(b) % 2 != 0 and len(c) > 0:
	print(len(b), end=' ')
	for i in b:
		print(i, end=' ')
	print(' ')
	print(len(c), end=' ')
	for i in c:
		print(i, end=' ')
	print(' ')
	print(len(d), end=' ')
	for i in d:
		print(i, end=' ')
elif len(b) % 2 == 0 and len(c) > 0:
	d.append(b[-1])
	b.remove(b[-1])
	print(len(b), end=' ')
	for i in b:
		print(i, end=' ')
	print(' ')
	print(len(c), end=' ')
	for i in c:
		print(i, end=' ')
	print(' ')
	print(len(d), end=' ')
	for i in d:
		print(i, end=' ')


n = int(input(''))
s = input('')
l = s.split(' ')
l = list(map(int, l))
neg = []
pos = []
zero = []
for i in range(n):
	if l[i] == 0:
		zero.append(l[i])
	elif l[i] > 0:
		pos.append(l[i])
	else:
		neg.append(l[i])
if len(neg) % 2 == 0:
	temp = neg.pop(len(neg) - 1)
	zero.append(temp)
if len(neg) % 2 != 0 and len(pos) == 0:
	temp = neg.pop(len(neg) - 1)
	temp1 = neg.pop(len(neg) - 2)
	pos.append(temp)
	pos.append(temp1)
print(len(neg), *neg, end='\n')
print(len(pos), *pos, end='\n')
print(len(zero), *zero, end='\n')


n = int(input())
a = [int(x) for x in input().split()]
n = []
p = []
z = []
tr = []
for x in a:
	if x == 0:
		z.append(x)
	elif x > 0:
		p.append(x)
	elif x < 0:
		if len(n) == 0:
			n.append(x)
		elif len(tr) < 2:
			tr.append(x)
		else:
			z.append(x)
if len(p) == 0:
	p = p + tr
else:
	z = z + tr
print(str(len(n)) + ' ' + ' '.join((str(x) for x in n)))
print(str(len(p)) + ' ' + ' '.join((str(x) for x in p)))
print(str(len(z)) + ' ' + ' '.join((str(x) for x in z)))


(a, b, c, extra) = ([], [], [], [])
input()
for i in map(int, input().split()):
	if i == 0:
		c.append(i)
	elif i > 0:
		if not b:
			b.append(i)
		else:
			c.append(i)
	elif not a:
		a.append(i)
	elif not b:
		extra.append(i)
		if len(extra) == 2:
			b.extend(extra)
			extra.clear()
	else:
		c.append(i)
c.extend(extra)
print(len(a), *a)
print(len(b), *b)
print(len(c), *c)


import sys
n = int(sys.stdin.readline())
group_1 = []
group_2 = []
group_3 = []
for s in sys.stdin.readline().split():
	i = int(s)
	if i == 0:
		group_3.append(i)
	elif i > 0:
		group_2.append(i)
	else:
		group_1.append(i)
if len(group_1) % 2 == 0:
	group_3.append(group_1[-1])
	group_1.pop()
if len(group_2) == 0:
	group_2 = group_1[-2:]
	group_1.pop()
	group_1.pop()
print(len(group_1), ' '.join(map(str, group_1)))
print(len(group_2), ' '.join(map(str, group_2)))
print(len(group_3), ' '.join(map(str, group_3)))


n = int(input())
a = list(map(int, input().split()))
(p1, p2, p3) = ([], [], [])
for i in a:
	if i > 0:
		p2.append(i)
	elif i < 0:
		p1.append(i)
	else:
		p3.append(i)
if len(p2) == 0:
	p2.append(p1[-2])
	p2.append(p1[-1])
	del p1[-2], p1[-1]
if len(p1) == 0:
	p1.append(p2[-1])
	del p2[-1]
if len(p1) % 2 == 0:
	p3.append(p1[-1])
	del p1[-1]
print(len(p1), end=' ')
for i in p1:
	print(i, end=' ')
print()
print(len(p2), end=' ')
for i in p2:
	print(i, end=' ')
print()
print(len(p3), end=' ')
for i in p3:
	print(i, end=' ')
print()


N = int(input())
A = list(map(int, input().split()))
neg = []
pos = []
z = []
p = 0
n = 0
c = 0
k = True
for item in A:
	if item < 0:
		n += 1
for item in A:
	if item > 0:
		if item not in pos:
			pos.append(item)
		elif item not in neg:
			neg.append(item)
		else:
			z.append(item)
	elif item == 0:
		z.append(item)
	else:
		c += 1
		if k and p >= 0 and (item not in neg):
			neg.append(item)
			p = -1
		elif k and item not in z:
			z.append(item)
		elif k and p < 0 and (c <= n) and (item not in neg):
			neg.append(item)
			p = 1
		elif item not in pos:
			pos.append(item)
			if k:
				k = False
			else:
				k = True
		elif p >= 0 and item not in neg:
			neg.append(item)
			p = -1
		elif item not in z:
			z.append(item)
		elif p < 0 and c <= n and (item not in neg):
			neg.append(item)
			p = 1
z.sort()
neg.sort()
x = 0
for item in neg:
	if item < 0:
		x += 1
if pos == []:
	if x > 2:
		pos.append(neg[0])
		pos.append(neg[1])
		neg.remove(neg[0])
		neg.remove(neg[0])
	else:
		pos.append(z[0])
		pos.append(z[1])
		z.remove(z[0])
		z.remove(z[0])
print(len(neg), end=' ')
for i in range(0, len(neg) - 1):
	print(neg[i], end=' ')
print(neg[len(neg) - 1])
print(len(pos), end=' ')
for i in range(0, len(pos) - 1):
	print(pos[i], end=' ')
print(pos[len(pos) - 1])
print(len(z), end=' ')
for i in range(0, len(z) - 1):
	print(z[i], end=' ')
print(z[len(z) - 1])


length = int(input())
arr = list(map(int, input().split()))
arr1 = []
arr2 = []
arr3 = []
arrTemp = []
neg_count = 0
pos_count = 0
for element in arr:
	if element > 0:
		pos_count += 1
		arr2.append(element)
	elif element < 0:
		neg_count += 1
		arrTemp.append(element)
	else:
		arr3.append(element)
if neg_count % 2 == 0 and pos_count == 0:
	for i in range(len(arrTemp)):
		if i == 0 or i == 1:
			arr2.append(arrTemp[i])
		elif i == 2:
			arr3.append(arrTemp[i])
		else:
			arr1.append(arrTemp[i])
elif neg_count % 2 == 0 and pos_count != 0:
	for i in range(len(arrTemp)):
		if i == 0:
			arr3.append(arrTemp[i])
		else:
			arr1.append(arrTemp[i])
elif neg_count % 2 == 1 and pos_count == 0:
	for i in range(len(arrTemp)):
		if i == 0 or i == 1:
			arr2.append(arrTemp[i])
		else:
			arr1.append(arrTemp[i])
else:
	arr1 = arrTemp

def printArr(arr):
	i = 0
	print(len(arr), end=' ')
	for i in range(len(arr)):
		if i < len(arr) - 1:
			print(arr[i], end=' ')
		else:
			print(arr[i])
printArr(arr1)
printArr(arr2)
printArr(arr3)


(n, t, p) = (int(input()), list(map(int, input().split())), {-1: [], 0: [], 1: []})
for i in t:
	p[int(i > 0) - int(i < 0)].append(str(i))
print(1, p[-1].pop())
if len(p[1]) == 0:
	print(2, p[-1].pop(), p[-1].pop())
else:
	print(1, p[1].pop())
p[0] += p[-1] + p[1]
print(len(p[0]), ' '.join(p[0]))


def printArr(a):
	print(len(a), end=' ')
	for x in a:
		print(x, end=' ')
	print()
n = int(input())
a = list(map(int, input().split()))
neg = [x for x in a if x < 0]
pos = [x for x in a if x > 0]
a1 = [neg.pop()]
if len(pos) > 0:
	a2 = [pos.pop()]
else:
	a2 = [neg.pop(), neg.pop()]
a3 = neg + pos + [0]
printArr(a1)
printArr(a2)
printArr(a3)


n = int(input())
a = []
a = input().split()
for i in range(0, n):
	a[i] = int(a[i])
p = []
n = []
null = []
for i in a:
	if i < 0:
		n.append(i)
	elif i > 0:
		p.append(i)
	else:
		null.append(i)
a1 = []
a2 = []
a3 = []
a1.append(n[0])
if len(p) >= 1:
	a2.append(p[0])
	if len(n) > 1:
		for i in range(1, len(n), 1):
			a3.append(n[i])
else:
	a2.append(n[1])
	a2.append(n[2])
	if len(n) > 3:
		for i in range(3, len(n), 1):
			a3.append(n[i])
if len(p) > 1:
	for i in range(1, len(p), 1):
		a3.append(p[i])
for i in range(0, len(null), 1):
	a3.append(null[i])
print(len(a1), end=' ')
for i in range(0, len(a1) - 1, 1):
	print(a1[i], end=' ')
print(a1[len(a1) - 1])
print(len(a2), end=' ')
for i in range(0, len(a2) - 1, 1):
	print(a2[i], end=' ')
print(a2[len(a2) - 1])
print(len(a3), end=' ')
for i in range(0, len(a3) - 1, 1):
	print(a3[i], end=' ')
print(a3[len(a3) - 1])


t = int(input())
n = list(map(int, input().split()))[:t]
a = []
b = []
c = []
for i in n:
	if i == 0:
		c.append(i)
	elif i < 0:
		a.append(i)
	else:
		b.append(i)
if len(a) % 2 == 0:
	c.append(a[0])
	a.remove(a[0])
if len(b) == 0:
	for i in range(2):
		b.append(a[0])
		a.remove(a[0])
print(len(a), *a)
print(len(b), *b)
print(len(c), *c)


_ = input()
arr = list(map(int, input().split()))
negative = []
positive = []
zero = []
for x in arr:
	if x < 0:
		negative.append(x)
	elif x > 0:
		positive.append(x)
	elif x == 0:
		zero.append(x)
if len(negative) % 2 == 0:
	zero.append(negative.pop())
if not positive:
	for _ in range(2):
		positive.append(negative.pop())
print(len(negative), *negative)
print(len(positive), *positive)
print(len(zero), *zero)


def writelist(li):
	print(str(len(li)) + ' ', end='')
	for x in li:
		print(str(x) + ' ', end='')
	print(' ')
n = int(input())
l = sorted(map(int, input().split()))
l1 = []
l2 = []
l3 = []
for i in l:
	if i == 0:
		l3.append(i)
	elif i < 0:
		l2.append(i)
	else:
		l1.append(i)
if len(l2) % 2 == 0:
	x = l2[0]
	l2.pop(0)
	l3.append(x)
if len(l1) == 0:
	l1.append(l2[0])
	l1.append(l2[1])
	l2.pop(0)
	l2.pop(0)
writelist(l2)
writelist(l1)
writelist(l3)


import sys
import math
n = int(sys.stdin.readline())
an = [int(x) for x in sys.stdin.readline().split()]
an1 = []
an2 = []
an3 = []
for i in an:
	if i == 0:
		an3.append(i)
	elif i > 0:
		an2.append(i)
	elif i < 0:
		an1.append(i)
if len(an2) == 0:
	an2.append(an1.pop(0))
	an2.append(an1.pop(1))
if len(an1) % 2 == 0:
	an3.append(an1.pop(0))
print(str(len(an1)) + ' ' + ' '.join([str(x) for x in an1]))
print(str(len(an2)) + ' ' + ' '.join([str(x) for x in an2]))
print(str(len(an3)) + ' ' + ' '.join([str(x) for x in an3]))


n = int(input())
a = list(map(int, input().split()))
(x, y, z) = ([], [], [])
for i in a:
	if i == 0:
		z.append(i)
	elif i > 0:
		y.append(i)
	else:
		x.append(i)
if len(y) == 0:
	y.append(x.pop())
	y.append(x.pop())
if len(x) % 2 == 0:
	z.append(x.pop())
print(len(x), end=' ')
for i in x:
	print(i, end=' ')
print()
print(len(y), end=' ')
for i in y:
	print(i, end=' ')
print()
print(len(z), end=' ')
for i in z:
	print(i, end=' ')


x = input()
nums = input().split(' ')
less = []
zero = []
greater = []
for x in nums:
	if int(x) < 0:
		less.append(int(x))
	if int(x) == 0:
		zero.append(int(x))
	if int(x) > 0:
		greater.append(int(x))
prod = less[0]
for i in range(1, len(less)):
	prod *= less[i]
if prod > 0:
	x = less.pop()
	zero.append(x)
if len(greater) == 0:
	x = less.pop()
	greater.append(x)
	x = less.pop()
	greater.append(x)
print(str(len(less)) + ' ' + ' '.join((str(x) for x in less)))
print(str(len(greater)) + ' ' + ' '.join((str(x) for x in greater)))
print(str(len(zero)) + ' ' + ' '.join((str(x) for x in zero)))


n = int(input())
list = [int(i) for i in input().split()]
(neg, pos, zero) = (0, 0, 0)
(posarr, zeroarr) = ([], [])
for i in range(n):
	if list[i] == 0:
		zero += 1
	elif list[i] < 0:
		neg += 1
	elif list[i] > 0:
		pos += 1
if zero + neg == n:
	(flag, j) = (True, 0)
	for i in range(n):
		if list[i] < 0 and flag:
			negarr = list[i]
			flag = False
		elif list[i] < 0 and j < 2:
			posarr.append(list[i])
			j += 1
		else:
			zeroarr.append(list[i])
	print(1, negarr)
	print(2, posarr[0], posarr[1])
	print(n - 3, end=' ')
	for i in range(n - 3):
		print(zeroarr[i], end=' ')
else:
	(flag1, flag2, zeroarr) = (True, True, [])
	for i in range(n):
		if list[i] < 0 and flag1:
			negarr = list[i]
			flag1 = False
		elif list[i] > 0 and flag2:
			posarr.append(list[i])
			flag2 = False
		else:
			zeroarr.append(list[i])
	print(1, negarr)
	print(1, posarr[0])
	print(n - 2, end=' ')
	for i in range(n - 2):
		print(zeroarr[i], end=' ')


n = int(input())
arr = input().split()
for i in range(n):
	arr[i] = int(arr[i])
arr.sort()
neg = '1 ' + str(arr[0])
c = 0
p = 0
for i in range(1, n):
	if arr[i] == 0:
		break
	c += 1
pos = ''
if c % 2 == 1:
	zor = '2 0 ' + str(arr[i - 1])
	c -= 1
else:
	zor = '1 0'
for j in range(1, c + 1):
	pos = pos + str(arr[j]) + ' '
for j in range(i + 1, n):
	pos = pos + str(arr[j]) + ' '
	c += 1
pos = str(c) + ' ' + pos
print(neg)
print(pos)
print(zor)


n = int(input())
t = list(map(int, input().split()))
a = []
b = []
c = []
for k in t:
	if k < 0:
		a.append(k)
	elif k > 0:
		b.append(k)
	else:
		c.append(k)
print(1, a[0])
a.remove(a[0])
if len(b) > 0:
	print(len(b), *b)
elif len(a) >= 2:
	print(2, *a[:2])
	a.remove(a[0])
	a.remove(a[0])
print(len(a) + len(c), *a + c)


n = int(input())
arr = list(map(int, input().split()))
neg = [x for x in arr if x < 0]
pos = [x for x in arr if x > 0]
a1 = [neg.pop()]
if len(pos) > 0:
	a2 = [pos.pop()]
else:
	a2 = [neg.pop(), neg.pop()]
a3 = neg + pos + [0]
print(len(a1), *a1)
print(len(a2), *a2)
print(len(a3), *a3)


import sys
from collections import defaultdict
n = int(sys.stdin.readline())
arr = list(map(int, sys.stdin.readline().split()))
s1 = []
s2 = []
s3 = []
negd = defaultdict()
posd = defaultdict()
zd = defaultdict()
negcount = 0
poscount = 0
zcount = 0
for i in range(len(arr)):
	if arr[i] < 0:
		negcount += 1
		negd[i] = arr[i]
	elif arr[i] > 0:
		poscount += 1
		posd[i] = arr[i]
	elif arr[i] == 0:
		zcount += 1
		zd[i] = arr[i]
if negcount % 2 != 0:
	if poscount > 0:
		s1 = list(negd.values())
		s2 = list(posd.values())
	else:
		s1 = list(negd.values())[:1]
		s2 = list(negd.values())[1:]
	s3 = list(zd.values())
else:
	s1 = list(negd.values())[:1]
	s2 = list(negd.values())[1:-1] + list(posd.values())
	s3 = list(zd.values()) + [list(negd.values())[-1]]
print(len(s1), end=' ')
print(*s1)
print(len(s2), end=' ')
print(*s2)
print(len(s3), end=' ')
print(*s3)


input()
a = sorted(map(int, input().split()))
b = [a.pop(0)]
c = a[-1] > 0 and [a.pop()] or [a.pop(0), a.pop(0)]
for L in (b, c, a):
	print(len(L), ' '.join(map(str, L)))


n = int(input())
l = list(map(int, input().split()))
(a, b) = ([], [])
s = 1
for i in l:
	if i < 0:
		a.append(i)
	elif i > 0:
		b.append(i)
print('1', a[0])
a.pop(0)
if len(b) == 0:
	print('2', end=' ')
	print(a[0], end=' ')
	print(a[1])
	s += 2
	a.pop(0)
	a.pop(0)
else:
	print('1', b[0])
	s += 1
	b.pop(0)
print(n - s, end=' ')
print('0', end=' ')
print(*a, end=' ')
print(*b)


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

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

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

def lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l

def sq(a, target, arr=[]):
	s = sum(arr)
	if s == target:
		return arr
	if s >= target:
		return
	for i in range(len(a)):
		n = a[i]
		remaining = a[i + 1:]
		ans = sq(remaining, target, arr + [n])
		if ans:
			return ans

def SieveOfEratosthenes(n):
	cnt = 0
	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
	for p in range(2, n + 1):
		if prime[p]:
			cnt += 1
	return cnt

def nCr(n, r):
	f = math.factorial
	return f(n) // f(r) // f(n - r)
mod = int(1000000000.0) + 7

def ssinp():
	return input()

def iinp():
	return int(input())

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

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

def p(xyz):
	print(xyz)

def p2(a, b):
	print(a, b)
import math
from collections import OrderedDict
n = iinp()
a = llinp()
a.sort()
ans1 = [a[0]]
a.remove(a[0])
ans2 = []
ans3 = []
pos = neg = 0
for c in a:
	if c < 0:
		neg += 1
	elif c > 0:
		pos += 1
if neg % 2 == 1:
	ans3 = [a[0]]
	a.remove(a[0])
for c in a:
	if c != 0:
		ans2.append(c)
	else:
		ans3.append(c)
print(len(ans1), end=' ')
print(*ans1)
print(len(ans2), end=' ')
print(*ans2)
print(len(ans3), end=' ')
print(*ans3)


n = int(input())
arr = list(map(int, input().split()))
neg = []
pos = []
zer = []
for i in arr:
	if i == 0:
		zer.append(i)
	if i < 0:
		neg.append(i)
	if i > 0:
		pos.append(i)
if len(pos) == 0:
	for i in range(0, 2):
		pos.append(neg[-1])
		neg.pop(-1)
if len(neg) % 2 == 0:
	zer.append(neg[-1])
	neg.pop(-1)
print(len(neg), end=' ')
for i in range(len(neg)):
	if i == len(neg) - 1:
		print(neg[i])
	else:
		print(neg[i], end=' ')
print(len(pos), end=' ')
for i in range(len(pos)):
	if i == len(pos) - 1:
		print(pos[i])
	else:
		print(pos[i], end=' ')
print(len(zer), end=' ')
for i in range(len(zer)):
	if i == len(zer) - 1:
		print(zer[i])
	else:
		print(zer[i], end=' ')


n = int(input())
a = sorted(map(int, input().split()))
x = a.index(0)
if x < n - 1:
	if x % 2:
		print(x, *a[:x])
		print(n - 1 - x, *a[x + 1:])
		print(1, a[x])
	else:
		print(x - 1, *a[:x - 1])
		print(n - 1 - x, *a[x + 1:])
		print(2, *a[x - 1:x + 1])
elif x % 2:
	print(x - 2, *a[:x - 2])
	print(2, *a[x - 2:x])
	print(1, a[x])
else:
	print(x - 3, *a[:x - 3])
	print(2, *a[x - 3:x - 1])
	print(2, *a[x - 1:])


def solution():
	n = int(input())
	a = list(map(int, input().split()))
	first = []
	second = []
	third = []
	for x in a:
		if x < 0:
			first.append(x)
		elif x > 0:
			second.append(x)
		else:
			third.append(x)
	if len(second) == 0:
		(second, first) = swapArray(first)
	if len(first) % 2 == 0:
		(first, third) = moveItem(first, third)
	f = str(len(first))
	s = str(len(second))
	t = str(len(third))
	for n in first:
		f += ' ' + str(n)
	for n in second:
		s += ' ' + str(n)
	for n in third:
		t += ' ' + str(n)
	print(f)
	print(s)
	print(t)

def swapArray(b):
	c = []
	d = []
	for y in range(0, 2):
		c.append(b[y])
	for x in range(2, len(b)):
		d.append(b[x])
	return (c, d)

def moveItem(a, b):
	x = a[0]
	b.append(x)
	c = []
	for y in a:
		if y != x:
			c.append(y)
	return (c, b)
solution()


def watermelon():
	n = int(input())
	if n > 3 and n % 2 == 0:
		print('YES')
	else:
		print('NO')

def way_to_long():
	for _ in range(int(input())):
		s = input()
		if len(s) > 10:
			print(s[0] + str(len(s) - 2) + s[-1])
		else:
			print(s)

def marks():
	(n, m) = map(int, input().split())
	arr = []
	for _ in range(n):
		arr.append(input())
	cnt = 0
	for i in range(n):
		for j in range(m):
			sub = arr[i][j]
			for k in range(n):
				if arr[k][j] > sub:
					break
			else:
				cnt += 1
				break
	print(cnt)

def c_strings():
	s = input()
	t = input()
	i = 0
	j = 0
	cnt = 1
	while i < len(s) and j < len(t):
		if s[i] == t[j]:
			cnt += 1
			i += 1
			j += 1
		else:
			j += 1
	print(cnt)

def domino():
	n = int(input())
	du = 0
	dl = 0
	cnt = 0
	for i in range(n):
		(x, y) = map(int, input().split())
		if x % 2 != 0 and y % 2 == 0 or (x % 2 == 0 and y % 2 != 0):
			cnt += 1
		du += x
		dl += y
	if du % 2 == 0 and dl % 2 == 0:
		print(0)
	elif du % 2 == 0 and dl % 2 != 0 or (du % 2 != 0 and dl % 2 == 0):
		print(-1)
	elif cnt > 1:
		print(1)
	else:
		print(-1)

def Cifera():
	import math
	n = int(input())
	l = int(input())
	x = int(round(math.log(l, n), 10))
	if n ** x == l:
		print('YES')
		print(x - 1)
	else:
		print('NO')

def array():
	n = int(input())
	arr = list(map(int, input().split()))
	f = []
	s = []
	t = []
	for i in arr:
		if i < 0:
			f.append(i)
		elif i == 0:
			t.append(i)
		else:
			s.append(i)
	if len(s) == 0:
		for i in range(2):
			s.append(f.pop())
	if len(f) % 2 == 0:
		t.append(f.pop())
	print(len(f), *f)
	print(len(s), *s)
	print(len(t), *t)
array()


x = int(input())
list = [int(x) for x in input().split()]
list = sorted(list)
(list1, list2, list3) = ([], [], [])
count = 0
for i in range(x):
	if list[i] > 0:
		list3.append(list[i])
	elif list[i] < 0 and count == 0:
		list1.append(list[i])
		count = count + 1
	else:
		list2.append(list[i])
if len(list3) == 0:
	list3.append(list[1])
	list3.append(list[2])
	list2.remove(list[1])
	list2.remove(list[2])
print(len(list1), end=' ')
for i in list1:
	print(i, end=' ')
print()
print(len(list3), end=' ')
for i in list3:
	print(i, end=' ')
print()
print(len(list2), end=' ')
for i in list2:
	print(i, end=' ')
print()


def divide_array(n, arr):
	negative = [str(x) for x in arr if x < 0]
	positive = [str(x) for x in arr if x > 0]
	zero = ['0'] * (n - len(negative) - len(positive))
	if len(negative) % 2 == 0:
		if len(positive) == 0:
			positive.append(negative.pop())
			positive.append(negative.pop())
			zero.append(negative.pop())
		else:
			zero.append(negative.pop())
	if len(positive) == 0:
		positive.append(negative.pop())
		positive.append(negative.pop())
	return (negative, positive, zero)
n = int(input())
arr = list(map(int, input().split()))
(negative, positive, zero) = divide_array(n, arr)
print(len(negative), ' '.join(negative))
print(len(positive), ' '.join(positive))
print(len(zero), ' '.join(zero))


n = int(input())
a = sorted(map(int, input().split()))
q = []
if a[-1] > 0:
	print(1, a[0])
	print(1, a[-1])
	for i in range(1, n - 1):
		q += [a[i]]
	print(n - 2, *q)
else:
	print(1, a[0])
	print(2, a[1], a[2])
	for i in range(3, n):
		q += [a[i]]
	print(n - 3, *q)


n = int(input())
a = [int(x) for x in input().split()]
negative = []
positive = []
for x in a:
	if x < 0:
		negative.append(x)
	elif x > 0:
		positive.append(x)
if len(positive) == 0:
	positive.append(negative.pop(0))
	positive.append(negative.pop(0))
length = len(negative)
temp = 1
if length % 2 == 0:
	temp = negative[0]
	negative.pop(0)
print(len(negative), end=' ')
for x in negative:
	print(x, end=' ')
print()
print(len(positive), end=' ')
for x in positive:
	print(x, end=' ')
print()
if temp < 0:
	print('2', temp, end=' ')
else:
	print('1', end=' ')
print('0')


n = int(input())
a = list(map(int, input().split()))
a.sort()
cntn = 0
cntp = 0
ind = a.index(0)
for i in range(n):
	if a[i] < 0:
		cntn += 1
	elif a[i] > 0:
		cntp += 1
if cntn % 2:
	if cntp > 0:
		l1 = [str(i) for i in a[:ind]]
		l2 = [str(a[-1])]
		a.pop()
		l3 = [str(i) for i in a[ind:]]
	else:
		l1 = [str(i) for i in a[:ind - 2]]
		l2 = [str(i) for i in a[ind - 2:ind]]
		l3 = [str(i) for i in a[ind:]]
elif cntp > 0:
	l1 = [str(i) for i in a[:ind - 1]]
	l2 = [str(a[-1])]
	a.pop()
	l3 = [str(i) for i in a[ind - 1:]]
else:
	l1 = [str(i) for i in a[:ind - 3]]
	l2 = [str(i) for i in a[ind - 3:ind - 1]]
	l3 = [str(i) for i in a[ind - 1:]]
print(len(l1), ' '.join(l1))
print(len(l2), ' '.join(l2))
print(len(l3), ' '.join(l3))


n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[2] < 0:
	print('1 %d' % a[2])
	print('2 %d %d' % (a[0], a[1]))
	print(n - 3, end=' ')
	for i in range(3, n - 1):
		print(a[i], end=' ')
	print(a[n - 1])
else:
	print('1 %d' % a[0])
	print('1 %d' % a[n - 1])
	print(n - 2, end=' ')
	for i in range(1, n - 2):
		print(a[i], end=' ')
	print(a[n - 2])


from math import *
from copy import *
from string import *
from random import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math

def bin1(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = k ** mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin1(mid + 1, r, k, t, b, val, ans)
		else:
			return bin1(l, mid - 1, k, t, b, val, ans)

def bin2(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = t * k ** mid + b * mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin2(l, mid - 1, k, t, b, val, ans)
		else:
			return bin2(mid + 1, r, k, t, b, val, ans)

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
	l = []
	for i in range(2, n + 1):
		if prime[i]:
			l.append(i)
	return l

def bin(l, r, ll, val):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		if val >= ll[mid][0] and val <= ll[mid][1]:
			return mid
		elif val < ll[mid][0]:
			return bin(l, mid - 1, ll, val)
		else:
			return bin(mid + 1, r, ll, val)

def deci(n):
	s = ''
	while n != 0:
		if n % 2 == 0:
			n = n // 2
			s = '0' + s
		else:
			n = n // 2
			s = '1' + s
	return s

def diff(s1, s2):
	if len(s1) < len(s2):
		v = len(s1)
		while v != len(s2):
			s1 = '0' + s1
			v = v + 1
	else:
		v = len(s2)
		while v != len(s1):
			s2 = '0' + s2
			v = v + 1
	c = 0
	for i in range(len(s1)):
		if s1[i:i + 1] != s2[i:i + 1]:
			c = c + 1
	return c
from sys import stdin, stdout

def fac(a, b):
	v = a
	while a != b:
		v *= a - 1
		a = a - 1
	return v

def bino(l, r, n):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		val1 = math.log(n / mid + 1, 2)
		val2 = int(val1)
		if val1 == val2:
			return val1
		elif val1 < 1.0:
			return bino(l, mid - 1, n)
		else:
			return bino(mid + 1, r, n)

def binary(l, r, ll, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		if val % ll[mid] == 0:
			ans = ll[mid]
			return binary(l, mid - 1, ll, val, ans)
		else:
			return binary(l, mid - 1, ll, val, ans)

def odd(n, ans, s):
	if n % 2 != 0 or n in s:
		return ans
	else:
		s.add(n)
		return odd(n // 2, ans + 1, s)
n = str(input())
l = list(map(int, input().split(' ')))
l.sort()
l1 = []
l2 = []
l3 = []
for i in l:
	if i < 0:
		if len(l1) == 0:
			l1.append(i)
		else:
			l3.append(i)
	elif i > 0:
		if len(l2) == 0:
			l2.append(i)
		else:
			l3.append(i)
	else:
		l3.append(i)
if len(l2) == 0:
	l2.append(l3[0])
	l2.append(l3[1])
	l4 = []
	for i in range(2, len(l3)):
		l4.append(l3[i])
	print(len(l1), *l1)
	print(len(l2), *l2)
	print(len(l4), *l4)
else:
	print(len(l1), *l1)
	print(len(l2), *l2)
	print(len(l3), *l3)


(a1, a2, a3, atmp) = ([], [], [], [])
n = int(input())
(neg, zero, pos, tmp) = (False, False, False, False)
for i in input().split():
	if int(i) < 0 and neg is False:
		neg = True
		a1.append(int(i))
	elif int(i) == 0 and zero is False:
		zero = True
		a3.append(int(i))
	elif int(i) > 0 and pos is False:
		if tmp is True:
			a3.append(atmp[0])
		pos = True
		a2.append(int(i))
	elif int(i) < 0 and neg is True and (pos is False):
		if tmp is False:
			tmp = True
			atmp.append(int(i))
		else:
			pos = True
			a2.append(atmp[0])
			a2.append(int(i))
	else:
		a3.append(int(i))
print(len(a1), end=' ')
for i in a1:
	print(i, end=' ')
print()
print(len(a2), end=' ')
for i in a2:
	print(i, end=' ')
print()
print(len(a3), end=' ')
for i in a3:
	print(i, end=' ')
print()


mn = 99999
n = int(input())
s = []
zero = 0
otr = 0
otrk = 0
otrelse = []
pair = []
v = list(map(int, input().split()))
for i in range(n):
	if v[i] == 0:
		zero += 1
	elif v[i] < 0:
		otrk += 1
		if otr != 0:
			if len(pair) < 2:
				pair.append(v[i])
			else:
				otrelse.append(v[i])
		else:
			otr = v[i]
	else:
		s.append(v[i])
print(1, otr)
if len(pair) == 2:
	s.append(pair[0])
	s.append(pair[1])
	print(len(s), *s)
	print(zero + len(otrelse), '0 ' * zero, *otrelse)
else:
	print(len(s), *s)
	print(zero + len(pair), '0 ' * zero, *pair)


def main():
	n = int(input())
	arr = list(map(int, input().strip().split()))
	arr.sort()
	pos = list()
	zero = list()
	neg = list()
	for i in arr:
		if i > 0:
			pos.append(i)
		elif i < 0:
			neg.append(i)
		elif i == 0:
			zero.append(i)
	del arr
	if len(pos) == 0:
		pos.append(neg.pop())
		pos.append(neg.pop())
	if len(neg) % 2 == 0:
		zero.append(neg.pop())
	print(len(neg), *neg)
	print(len(pos), *pos)
	print(len(zero), *zero)
main()


n = int(input())
a = list(map(int, input().split()))
(neg, pos) = (0, 0)
ans = []
for i in a:
	if i > 0 and pos == 0:
		pos = i
	elif i < 0 and neg == 0:
		neg = i
	else:
		ans.append(i)
print(1, neg)
if pos > 0:
	print(1, pos)
	print(n - 2, *ans)
else:
	print(2, *[val for val in ans if val < 0][:2])
	cnt = 2
	print(n - 3, end=' ')
	for i in ans:
		if i < 0:
			if cnt > 0:
				cnt -= 1
				continue
		print(i, end=' ')


n = int(input())
l1 = list(map(int, input().split()))
neg = 0
zeroes = 0
pos = 0
for item in l1:
	if item < 0:
		neg += 1
	elif item == 0:
		zeroes += 1
	else:
		pos += 1
ans1 = []
ans2 = []
ans3 = []
if pos == 0:
	flag1 = 0
	flag2 = 0
	flag3 = 0
	for item in l1:
		if item < 0:
			if flag1 == 0:
				ans1.append(item)
				flag1 = 1
			elif flag3 == 0 or flag3 == 1:
				ans3.append(item)
				flag3 += 1
			else:
				ans2.append(item)
		else:
			ans2.append(item)
else:
	flag1 = 0
	flag2 = 0
	flag3 = 0
	for item in l1:
		if item < 0:
			if flag1 == 0:
				ans1.append(item)
				flag1 = 1
			else:
				ans2.append(item)
		elif item > 0:
			if flag3 == 0:
				ans3.append(item)
				flag3 = 1
			else:
				ans2.append(item)
		else:
			ans2.append(item)
print(len(ans1), ' '.join((str(x) for x in ans1)))
print(len(ans3), ' '.join((str(x) for x in ans3)))
print(len(ans2), ' '.join((str(x) for x in ans2)))


number = int(input())
negative = []
positive = []
zero = []
numbers = input().split()
for number in numbers:
	if int(number) < 0:
		negative.append(number)
	elif int(number) > 0:
		positive.append(number)
	else:
		zero.append(number)
if len(positive) == 0:
	positive.extend(negative[-1:-3:-1])
	del negative[-1]
	del negative[-1]
if len(negative) % 2 == 0:
	zero.append(negative[-1])
	del negative[-1]
print('%s %s' % (len(negative), ' '.join(negative)))
print('%s %s' % (len(positive), ' '.join(positive)))
print('%s %s' % (len(zero), ' '.join(zero)))


p = int(input())
q = list((int(x) for x in input().split()))
a = []
b = []
c = []
for i in q:
	if i < 0:
		a.append(i)
	elif i > 0:
		b.append(i)
	else:
		c.append(i)
if len(b) == 0 and len(a) > 2:
	for i in range(2):
		b.append(a[i])
	a.remove(a[0])
	a.remove(a[0])
while len(a) > 1:
	c.append(a[1])
	a.remove(a[1])
print(len(a), end=' ')
for i in a:
	print(i, end=' ')
print()
print(len(b), end=' ')
for i in b:
	print(i, end=' ')
print()
print(len(c), end=' ')
for i in c:
	print(i, end=' ')


n = int(input())
l = list(map(int, input().split()))
under_zero = list(filter(lambda x: x < 0, l))
greater_zero = list(filter(lambda x: x > 0, l))
equal_zero = list(filter(lambda x: x == 0, l))
if len(greater_zero) == 0:
	greater_zero.append(under_zero[len(under_zero) - 1])
	greater_zero.append(under_zero[len(under_zero) - 2])
	under_zero = under_zero[:len(under_zero) - 2]
if len(under_zero) % 2 == 0:
	equal_zero.append(under_zero[len(under_zero) - 1])
	under_zero = under_zero[:len(under_zero) - 1]
print(len(under_zero), end=' ')
for i in under_zero:
	print(i, end=' ')
print()
print(len(greater_zero), end=' ')
for i in greater_zero:
	print(i, end=' ')
print()
print(len(equal_zero), end=' ')
for i in equal_zero:
	print(i, end=' ')


n = int(input())
x = list(map(int, input().split()))
(a, b, c) = ([], [], [])
cnt_positive = 0
cnt_negative = 0
flag = 0
flag2 = 0
for j in range(n):
	if x[j] > 0:
		cnt_positive += 1
	elif x[j] < 0:
		cnt_negative += 1
for i in range(n):
	if x[i] < 0 and flag == 0:
		a.append(x[i])
		flag = 1
	elif x[i] < 0 and cnt_positive == 0 and (flag2 < 2) or (cnt_positive != 0 and x[i] > 0):
		b.append(x[i])
		flag2 += 1
	else:
		c.append(x[i])
for _ in (a, b, c):
	print(len(_), *_)


n = input()
s = [[], [], [0]]
s_1 = 0
for el in map(int, input().split()):
	if el < 0:
		s[0].append(el)
	elif el > 0:
		s[1].append(el)
if len(s[1]) == 0:
	s[1] = s[0][:2]
	s[0] = s[0][2:]
if len(s[0]) % 2 == 0:
	s[2].append(s[0][0])
	s[0] = s[0][1:]
for el in s:
	print(len(el), ' '.join(map(str, el)))


def array(n_int: int, numbers_list: list) -> None:
	neg_numbers = []
	pos_numbers = []
	set_1 = []
	set_2 = []
	set_3 = []
	for number in numbers_list:
		if number > 0:
			pos_numbers.append(number)
		elif number < 0:
			neg_numbers.append(number)
		else:
			set_3.append(number)
	set_1.append(neg_numbers.pop())
	if len(pos_numbers) == 0:
		set_2.append(neg_numbers.pop())
		set_2.append(neg_numbers.pop())
	else:
		while len(pos_numbers) > 0:
			set_2.append(pos_numbers.pop())
	for each in neg_numbers:
		set_3.append(each)
	for each in pos_numbers:
		set_3.append(each)
	print(len(set_1), *set_1)
	print(len(set_2), *set_2)
	print(len(set_3), *set_3)
n = int(input())
numbers = list(map(int, input().split()))
array(n, numbers)


n = int(input())
lst = list(map(int, input().split()))
positive = []
negative = []
zero = []
set1 = []
set2 = []
set3 = []
for i in lst:
	if i > 0:
		positive.append(i)
	elif i == 0:
		zero.append(i)
	else:
		negative.append(i)
if len(positive) == 0:
	set1.append(negative[0])
	set2.append(negative[1])
	set2.append(negative[2])
	for i in (positive, zero):
		for j in i:
			set3.append(j)
	for i in negative[3:]:
		set3.append(i)
else:
	set1.append(negative[0])
	for i in positive:
		set2.append(i)
	for i in negative[1:]:
		set3.append(i)
	for i in zero:
		set3.append(i)
for i in (set1, set2, set3):
	print(len(i), end=' ')
	for j in i:
		print(j, end=' ')
	print()


n = int(input())
a = list(map(int, input().split()))
b = []
c = []
d = []
for i in a:
	if i < 0:
		b.append(i)
	elif i == 0:
		c.append(i)
	else:
		d.append(i)
print(1, b[0])
del b[0]
try:
	print(1, d[0])
	del d[0]
except:
	print(2, b[0], b[1])
	del b[0]
	del b[0]
print(len(b) + len(c) + len(d), *b, *c, *d)


n = input()
l = [int(x) for x in input().split(' ')]
arr = sorted(l)
neg = [arr.pop(0)]
if arr[-1] > 0:
	pos = [arr.pop()]
else:
	pos = [arr.pop(0), arr.pop(0)]
for i in (neg, pos, arr):
	print(len(i), end=' ')
	for k in i:
		print(k, end=' ')
	print()


def check_1(list, x):
	if len(list) == 0 and x < 0:
		return True
	else:
		return False

def check_2_in_special(list, x):
	if len(list) < 2 and x != 0:
		return True
	else:
		return False

def check_2(list, x):
	if len(list) == 0 and x > 0:
		return True
	else:
		return False

def cout(x):
	print(len(x), end=' ')
	for k in x:
		print(k, end=' ')
	print('')

def check_all_negative(x):
	flag = True
	for k in x:
		if k > 0:
			flag = False
	return flag
n = int(input())
a = list(map(int, input().split()))
set_1 = []
set_2 = []
set_3 = []
if check_all_negative(a) == True:
	for k in a:
		if check_1(set_1, k) == True:
			set_1.append(k)
		elif check_2_in_special(set_2, k) == True:
			set_2.append(k)
		else:
			set_3.append(k)
else:
	for k in a:
		if check_1(set_1, k) == True:
			set_1.append(k)
		elif check_2(set_2, k) == True:
			set_2.append(k)
		else:
			set_3.append(k)
cout(set_1)
cout(set_2)
cout(set_3)


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
from bisect import bisect_right

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

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

def I():
	return int(stdin.readline())
P = 1000000007

def main():
	n = I()
	arr = L()
	arr1 = []
	arr2 = []
	arr3 = [0]
	for i in arr:
		if i < 0:
			arr1.append(i)
		elif i > 0:
			arr2.append(i)
	if len(arr2) == 0:
		x = arr1.pop()
		arr2.append(x)
		x = arr1.pop()
		arr2.append(x)
	if len(arr1) % 2 == 0:
		x = arr1.pop()
		arr3.append(x)
	arr1.sort()
	arr2.sort()
	arr3.sort()
	print(len(arr1), *arr1)
	print(len(arr2), *arr2)
	print(len(arr3), *arr3)
main()


def main():
	n = int(input())
	nums = list(map(int, input().split(' ')))
	positives = []
	negatives = []
	zeros = []
	a = []
	b = []
	c = []
	for num in nums:
		if num == 0:
			zeros.append(num)
		elif num < 0:
			negatives.append(num)
		else:
			positives.append(num)
	if len(positives) == 0:
		positives.append(negatives.pop())
		positives.append(negatives.pop())
	for i in range(len(negatives)):
		if i == len(negatives) - 1 and len(a) % 2 != 0:
			zeros.append(negatives[i])
		else:
			a.append(negatives[i])
	for pos in positives:
		b.append(pos)
	for zero in zeros:
		c.append(zero)
	print('{} {}'.format(len(a), ' '.join(map(str, a))))
	print('{} {}'.format(len(b), ' '.join(map(str, b))))
	print('{} {}'.format(len(c), ' '.join(map(str, c))))
main()


n = int(input())
a = list(map(int, input().split()))
n1 = 0
n2 = 0
n3 = 0
a1 = []
a2 = []
a3 = []
for i in a:
	if i < 0:
		n1 += 1
		a1.append(i)
	if i > 0:
		n2 += 1
		a2.append(i)
	if i == 0:
		n3 += 1
		a3.append(i)
if n1 == 0:
	a1.append(a2[-1])
	a3.append(a2[-2])
	a2.remove(a2[-1])
	a2.remove(a2[-1])
	n1 += 1
	n3 += 1
	n2 -= 2
if n2 == 0:
	a2.append(a1[-1])
	a2.append(a1[-2])
	a1.remove(a1[-1])
	a1.remove(a1[-1])
	n2 += 2
	n1 -= 2
proda1 = 1
for i in a1:
	proda1 *= i
if proda1 > 0:
	a3.append(a1[-1])
	a1.remove(a1[-1])
	n3 += 1
	n1 -= 1
print(n1, end=' ')
for i in range(len(a1)):
	print(a1[i], end=' ')
print()
print(n2, end=' ')
for i in range(len(a2)):
	print(a2[i], end=' ')
print()
print(n3, end=' ')
for i in range(len(a3)):
	print(a3[i], end=' ')


n = int(input())
zero = sorted(map(int, input().split()))
neg = [zero.pop(0)]
pos = zero[-1] > 0 and [zero.pop()] or [zero.pop(0), zero.pop(0)]
for each in (neg, pos, zero):
	print(len(each), *each)


N = int(input())
arr = list(map(int, input().split()))
(n, z, p) = ([], [], [])
for i in arr:
	if i < 0:
		n.append(i)
	elif i == 0:
		z.append(i)
	else:
		p.append(i)
if len(p) == 0:
	p.append(n.pop())
	p.append(n.pop())
if len(n) % 2 == 0:
	z.append(n.pop())
print(len(n), *n)
print(len(p), *p)
print(len(z), *z)


N = int(input())
l = list(map(int, input().split()))
n = []
p = []
o = []
for i in range(N):
	if l[i] < 0:
		n.append(l[i])
	elif l[i] == 0:
		o.append(l[i])
	else:
		p.append(l[i])
if len(p) == 0 and len(n) > 2:
	p.append(n[len(n) - 1])
	p.append(n[len(n) - 2])
	n.pop()
	n.pop()
	if len(n) % 2 == 0:
		o.append(n[len(n) - 1])
		n.pop()
elif len(n) % 2 == 0:
	o.append(n[len(n) - 1])
	n.pop()
print(len(n), end=' ')
for i in range(len(n) - 1):
	print(n[i], end=' ')
print(n[len(n) - 1])
print(len(p), end=' ')
for i in range(len(p) - 1):
	print(p[i], end=' ')
print(p[len(p) - 1])
print(len(o), end=' ')
for i in range(len(o) - 1):
	print(o[i], end=' ')
print(o[len(o) - 1])


a = input()
arr = list(map(int, input().split()))
arr.sort()
n = len(arr)
x = arr.index(0)
if x + 1 == n:
	if x % 2 != 0:
		print(x - 2, end=' ')
		for i in range(2, x):
			print(arr[i], end=' ')
		print('\n', end='')
		print(2, end=' ')
		print(arr[0], end=' ')
		print(arr[1])
		print(1, end=' ')
		print(arr[x])
	else:
		print(x - 3, end=' ')
		for i in range(2, x - 1):
			print(arr[i], end=' ')
		print('\n', end='')
		print(2, end=' ')
		print(arr[0], end=' ')
		print(arr[1])
		print(2, end=' ')
		print(arr[x - 1], end=' ')
		print(arr[x])
else:
	print(1, end=' ')
	print(arr[0])
	print(n - x - 1, end=' ')
	for i in range(x + 1, n):
		print(arr[i], end=' ')
	print('\n', end='')
	print(x, end=' ')
	for i in range(1, x + 1):
		print(arr[i], end=' ')


p = []
n = []
z = []
n1 = int(input())
a = [int(i) for i in input().split()]
for i in a:
	if i == 0:
		z.append(0)
	elif i > 0:
		p.append(i)
	else:
		n.append(i)
if len(p) == 0 and len(n) % 2:
	p.append(n.pop())
	p.append(n.pop())
elif len(p) == 0 and len(n) % 2 == 0:
	z.append(n.pop())
	p.append(n.pop())
	p.append(n.pop())
elif len(n) % 2 == 0 and len(p) > 0:
	z.append(n.pop())
print(len(n), *n)
print(len(p), *p)
print(len(z), *z)


n = int(input())
a = list(map(int, input().split()))
arr1 = []
arr2 = []
arr3 = []
for i in range(n):
	if a[i] < 0:
		arr1.append(a[i])
	if a[i] == 0:
		arr3.append(a[i])
	if a[i] > 0:
		arr2.append(a[i])
if len(arr2) == 0:
	for i in range(2):
		arr2.append(arr1.pop())
if len(arr1) % 2 == 0:
	arr3.append(arr1.pop(-1))
print('%d' % len(arr1), end=' ')
for i in range(len(arr1)):
	print(arr1[i], end=' ')
print('\n%d' % len(arr2), end=' ')
for i in range(len(arr2)):
	print(arr2[i], end=' ')
print('\n%d' % len(arr3), end=' ')
for i in range(len(arr3)):
	print(arr3[i], end=' ')


n = int(input())
arr = list(map(int, input().split()))
less = [x for x in arr if x < 0]
more = [x for x in arr if x > 0]
zero = [x for x in arr if x == 0]
if len(less) % 2 == 0:
	zero.append(less.pop())
if len(more) == 0 and len(less) > 2:
	more.append(less.pop())
	more.append(less.pop())
print(len(less), ' '.join([str(x) for x in less]))
print(len(more), ' '.join([str(x) for x in more]))
print(len(zero), ' '.join([str(x) for x in zero]))


n = int(input())
a = list(map(int, input().split()))
a.sort()
n2 = []
neg = 1
print(1, a[0])
for i in range(1, n):
	if a[i] < 0:
		neg += 1
if neg % 2 == 1:
	for i in range(1, n):
		if a[i] != 0:
			n2.append(a[i])
	print(len(n2), *n2)
	print(a.count(0), '0 ' * a.count(0))
else:
	for i in range(2, n):
		if a[i] != 0:
			n2.append(a[i])
	print(len(n2), *n2)
	print(a.count(0) + 1, '0 ' * a.count(0), a[1])


r = int(input())
l = list(map(int, input().split()))
p = []
n = []
z = []
for i in l:
	if i < 0:
		n.append(i)
	elif i > 0:
		p.append(i)
	else:
		z.append(i)
if len(n) % 2 == 0:
	if len(p) == 0:
		p.append(n[0])
		n.remove(n[0])
		p.append(n[0])
		n.remove(n[0])
		z.append(n[0])
		n.remove(n[0])
	else:
		z.append(n[0])
		n.remove(n[0])
elif len(p) == 0:
	p.append(n[0])
	n.remove(n[0])
	p.append(n[0])
	n.remove(n[0])
print(len(n), end=' ')
for i in n:
	print(i, end=' ')
print()
print(len(p), end=' ')
for i in p:
	print(i, end=' ')
print()
print(len(z), end=' ')
for i in z:
	print(i, end=' ')
print()


t = int(input())
x = [int(q) for q in input().split()]
a = []
b = []
c = []

def ex(x, i):
	return x[0:i] + x[i + 1:]
for i in range(len(x)):
	if x[i] > 0:
		a.append(x[i])
	if x[i] == 0:
		c.append(x[i])
	if x[i] < 0:
		b.append(x[i])
if len(a) == 0:
	if len(b) % 2 == 0:
		a.append(b[-1])
		b = ex(b, len(b) - 1)
		a.append(b[-1])
		b = ex(b, len(b) - 1)
		c.append(b[-1])
		b = ex(b, len(b) - 1)
	else:
		a.append(b[-1])
		b = ex(b, len(b) - 1)
		a.append(b[-1])
		b = ex(b, len(b) - 1)
if len(a) != 0:
	if len(b) % 2 == 0:
		c.append(b[-1])
		b = ex(b, len(b) - 1)
print(len(b), *b)
print(len(a), *a)
print(len(c), *c)


try:
	n = int(input())
	l = list(map(int, input().split()))
	p = []
	ne = []
	e = []
	for i in range(0, n):
		if l[i] < 0:
			ne.append(l[i])
		elif l[i] > 0:
			p.append(l[i])
		else:
			e.append(l[i])
	if len(p) == 0:
		p.append(ne.pop())
		p.append(ne.pop())
	if len(ne) % 2 == 0:
		e.append(ne.pop())
	print(len(ne), *ne)
	print(len(p), *p)
	print(len(e), *e)
except Exception:
	pass


n = int(input())
s = list(map(int, input().split()))
a = []
b = []
c = []
for i in range(n):
	if s[i] < 0:
		a.append(s[i])
	elif s[i] > 0:
		b.append(s[i])
	else:
		c.append(s[i])
if len(a) % 2 == 0:
	d = a.pop()
	c.append(d)
if len(b) == 0:
	e = a.pop()
	b.append(e)
	f = a.pop()
	b.append(f)
print(len(a), *list(a))
print(len(b), *list(b))
print(len(c), *list(c))


n = int(input())
array = list(map(int, input().split()))
n1 = list()
n2 = list()
n3 = list()
for i in array:
	if i > 0:
		n1.append(i)
	elif i < 0:
		n2.append(i)
	else:
		n3.append(i)
if len(n2) % 2 == 0:
	n1.append(n2[-1])
	n3.append(n2[-2])
	n2_tmp = n2[0:len(n2) - 2]
	n2 = n2_tmp[:]
else:
	n1.append(n2[-1])
	n2_tmp = n2[0:len(n2) - 1]
	n2 = n2_tmp[:]
if len(n2) == 0:
	n2.append(n1[0])
	n1_tmp = n1[1:len(n1)]
	n1 = n1_tmp[:]
print(len(n1), end=' ')
for n in range(len(n1)):
	if n == len(n1) - 1:
		print(n1[n])
	else:
		print(n1[n], end=' ')
print(len(n2), end=' ')
for n in range(len(n2)):
	if n == len(n2) - 1:
		print(n2[n])
	else:
		print(n2[n], end=' ')
print(len(n3), end=' ')
for n in range(len(n3)):
	if n == len(n3) - 1:
		print(n3[n])
	else:
		print(n3[n], end=' ')


n = int(input())
l = list(map(int, input().split()))
pos = [x for x in l if x > 0]
neg = [x for x in l if x < 0]
zeros = [x for x in l if x == 0]
if len(pos) > 0:
	print(f'{1} {neg[0]}')
	print(f'{1} {pos[0]}')
	sol = [x for x in pos[1:] + neg[1:] + zeros]
else:
	print(f'{1} {neg[2]}')
	print(f'{2} {neg[0]} {neg[1]}')
	sol = [x for x in neg[3:] + zeros]
print(len(sol), end=' ')
print(*sol, end=' ')


x = int(input())
A = input().split()
p = []
n = []
z = []
for i in A:
	k = int(i)
	if k < 0:
		n.append(k)
	elif k > 0:
		p.append(k)
	else:
		z.append(k)
if len(p) == 0:
	p.append(n[0])
	p.append(n[1])
	del n[0:2]
if len(n) % 2 == 0:
	z.append(n[0])
	n.pop(0)
print(len(n), end=' ')
for i in n:
	print(int(i), end=' ')
print()
print(len(p), end=' ')
for i in p:
	print(int(i), end=' ')
print()
print(len(z), end=' ')
for i in z:
	print(int(i), end=' ')


input()
a = sorted(map(int, input().split()))
b = [a.pop(0)]
c = [a.pop()] if a[-1] > 0 else [a.pop(0), a.pop(0)]
for L in (b, c, a):
	print(len(L), ' '.join(map(str, L)))


n = int(input())
l = list(map(int, input().split()))
gotn = 0
gotz = 0
cou = 0
for i in range(n):
	if l[i] < 0 and gotn == 0:
		a = l.pop(i)
		gotn = 1
	if l[i] == 0 and gotz == 0:
		l.pop(i)
		gotz = 1
	if gotn and gotz:
		break
lol = 0
for i in range(len(l)):
	if l[i] < 0:
		cou += 1
		if lol == 0:
			lol = 1
			b = l[i]
			ind = i
print(1, a)
if cou % 2 == 1:
	l.pop(ind)
print(len(l), *l)
if cou % 2 == 1:
	print(2, 0, b)
else:
	print(1, 0)


n = int(input())
arr = list(map(int, input().split()))
ps = 0
ne = 0
for i in arr:
	if i > 0:
		ps += 1
	elif i < 0:
		ne += 1
ng = []
p = []
z = []
if ps == 0:
	if ne % 2 == 0:
		f = 0
		for i in arr:
			if i < 0 and len(ng) <= 0:
				ng.append(i)
			elif i == 0 or (f == 0 and i < 0):
				f = 1
				z.append(i)
			else:
				p.append(i)
	else:
		for i in arr:
			if i < 0 and len(ng) == 0:
				ng.append(i)
			elif i == 0:
				z.append(i)
			else:
				p.append(i)
else:
	for i in arr:
		if i < 0 and len(ng) == 0:
			ng.append(i)
		elif i == 0 or i < 0:
			z.append(i)
		else:
			p.append(i)
print(len(ng), *ng)
print(len(p), *p)
print(len(z), *z)


n = int(input())
a = list(map(int, input().split()))
pos1 = -1
(neg1, neg2, neg3) = (-1, -1, -1)
for i in range(len(a)):
	if a[i] > 0:
		pos1 = i
	elif a[i] < 0:
		if neg1 == -1:
			neg1 = i
		elif neg2 == -1:
			neg2 = i
		else:
			neg3 = i
if pos1 != -1:
	print(1, a[neg1])
	print(1, a[pos1])
	print(n - 2, end=' ')
	for i in range(n):
		if i != neg1 and i != pos1:
			print(a[i], end=' ')
else:
	print(1, a[neg1])
	print(2, a[neg2], a[neg3])
	print(n - 3, end=' ')
	for i in range(n):
		if i not in [neg1, neg2, neg3]:
			print(a[i], end=' ')


n = int(input())
l = list(map(int, input().split()))
n = []
z = []
o = []
o = ['0'] * l.count(0)
n = [str(i) for i in l if i < 0]
z = [str(i) for i in l if i > 0]
if len(z) == 0:
	z = z + [str(n[0]), str(n[1])]
	del n[0]
	del n[0]
if len(n) % 2 == 0:
	o.append(str(n[0]))
	del n[0]
print(len(n), ' '.join(n))
print(len(z), ' '.join(z))
print(len(o), ' '.join(o))


def neg_cnt(a):
	cnt = 0
	for i in a:
		if i < 0:
			cnt += 1
	return cnt
n = int(input())
a = list(map(int, input().split()))
neg = []
pos = []
zero = []
if neg_cnt(a) % 2 == 0:
	flag1 = False
	flag2 = False
	for i in a:
		if i < 0:
			if not flag1:
				zero.append(i)
				flag1 = True
			elif not flag2:
				neg.append(i)
				flag2 = True
			else:
				pos.append(i)
		elif i > 0:
			pos.append(i)
		else:
			zero.append(i)
else:
	flag1 = False
	for i in a:
		if i < 0:
			if not flag1:
				neg.append(i)
				flag1 = True
			else:
				pos.append(i)
		elif i > 0:
			pos.append(i)
		else:
			zero.append(i)
print(len(neg), end=' ')
for i in neg:
	print(i, end=' ')
print()
print(len(pos), end=' ')
for i in pos:
	print(i, end=' ')
print()
print(len(zero), end=' ')
for i in zero:
	print(i, end=' ')
print()


import os
import sys
from io import BytesIO, IOBase
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 main():
	try:
		n = inp()
		a = inlt()
		(one, two, three) = ([], [], [])
		for i in range(len(a)):
			if a[i] < 0:
				one.append(a[i])
			elif a[i] == 0:
				three.append(a[i])
			else:
				two.append(a[i])
		if len(two) == 0 and len(one) > 2:
			two.append(one.pop())
			two.append(one.pop())
		if len(one) % 2 == 0:
			three.append(one.pop())
		print(len(one), *one, sep=' ')
		print(len(two), *two, sep=' ')
		print(len(three), *three, sep=' ')
	except Exception as e:
		print(e)
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()


input()
a = [int(x) for x in input().split()]
(p, q, r) = (list(), list(), list())
for i in a:
	if i < 0:
		p.append(i)
	elif i > 0:
		q.append(i)
	else:
		r.append(i)
if len(q) == 0:
	q.append(p.pop())
	q.append(p.pop())
if len(p) > 1 and len(p) % 2 == 0:
	r.append(p.pop())
print(len(p), end=' ')
print(*p)
print(len(q), end=' ')
print(*q)
print(len(r), end=' ')
print(*r)


n = int(input())
a = list(map(int, input().split()))
pos = []
neg = []
zero = []
for x in a:
	if x == 0:
		zero.append(x)
	elif x < 0:
		neg.append(x)
	else:
		pos.append(x)
if len(pos) == 0:
	print(1, end=' ')
	print(neg[0], end=' ')
	print()
	print(2, end=' ')
	for i in range(1, 3):
		print(neg[i], end=' ')
	print()
	print(len(zero) + len(neg) - 3, end=' ')
	for i in range(3, len(neg)):
		print(neg[i], end=' ')
	for x in zero:
		print(x, end=' ')
	print()
else:
	print(1, end=' ')
	print(neg[0], end=' ')
	print()
	print(len(pos), end=' ')
	for i in range(len(pos)):
		print(pos[i], end=' ')
	print()
	print(len(zero) + len(neg) - 1, end=' ')
	for i in range(1, len(neg)):
		print(neg[i], end=' ')
	for x in zero:
		print(x, end=' ')
	print()


n = int(input())
a = list(map(int, input().split()))
neg = []
pos = []
zero = [0]
for i in range(len(a)):
	if a[i] < 0:
		neg.append(a[i])
	elif a[i] > 0:
		pos.append(a[i])
print('1 ' + str(neg[0]))
if len(neg[1:]) % 2 == 0:
	pos += neg[1:]
else:
	pos += neg[1:len(neg) - 1]
	zero.append(neg[-1])
print(str(len(pos)) + ' ' + ' '.join(map(str, pos)))
print(str(len(zero)) + ' ' + ' '.join(map(str, zero)))


m = int(input())
l = list(map(int, input().split()))
(p, n, z) = ([], [], [])
for i in range(m):
	if l[i] > 0:
		p.append(l[i])
	elif l[i] < 0:
		n.append(l[i])
	else:
		z.append(l[i])
if not p:
	p = n[:2]
	n = n[2:]
print(1, n[0])
print(len(p), *p)
print(len(z) + len(n) - 1, *z, *n[1:])


n = int(input())
a = list(map(int, input().split(' ')))
neg = []
pos = []
zero = []
for i in a:
	if i == 0:
		zero.append(i)
	if i > 0:
		pos.append(i)
	if i < 0:
		neg.append(i)
if len(pos) == 0:
	pos.append(neg[0])
	del neg[0]
	pos.append(neg[0])
	del neg[0]
if len(neg) % 2 == 0:
	zero.append(neg[0])
	del neg[0]
print(len(neg), ' '.join(list(map(str, neg))))
print(len(pos), ' '.join(list(map(str, pos))))
print(len(zero), ' '.join(list(map(str, zero))))


n = int(input())
s = list(map(int, input().split()))
s.sort()
print(1, end=' ')
print(s[0])
if s[-1] == 0:
	print(2, end=' ')
	print(s[1], end=' ')
	print(s[2])
	print(n - 3, end=' ')
	i = 3
	while i < n:
		print(s[i], end=' ')
		i = i + 1
else:
	print(1, end=' ')
	print(s[-1])
	print(n - 2, end=' ')
	j = 1
	while j < n - 1:
		print(s[j], end=' ')
		j += 1


t = int(input())
arr = list(map(int, input().split()))
less = []
great = []
zero = []
for i in range(t):
	if arr[i] == 0:
		zero.append(0)
	elif arr[i] < 0:
		if len(less) == 0:
			less.append(arr[i])
		else:
			great.append(arr[i])
	else:
		great.append(arr[i])
pos = -1
count = 0
for i in range(len(great)):
	if great[i] < 0:
		pos = i
		count += 1
if count % 2 == 1:
	x = great[pos]
	del great[pos]
	zero.append(x)
print(len(less), *less)
print(len(great), *great)
print(len(zero), *zero)


n = int(input())
arr = [int(x) for x in input().strip().split()]
neg = [x for x in arr if x < 0]
zero = [x for x in arr if x == 0]
pos = [x for x in arr if x > 0]
if len(pos) == 0:
	pos.append(neg.pop())
	pos.append(neg.pop())
if len(neg) == 0:
	neg.append(pos.pop())
	neg.append(pos.pop())
if len(neg) % 2 == 0:
	zero.append(neg.pop())
neg = str(len(neg)) + ' ' + ' '.join([str(x) for x in neg])
pos = str(len(pos)) + ' ' + ' '.join([str(x) for x in pos])
zero = str(len(zero)) + ' ' + ' '.join([str(x) for x in zero])
print(neg)
print(pos)
print(zero)


(st, nd, rd) = ([], [], [])
input()
nums = sorted(input().split())
if int(nums[-1]) > 0:
	st.append(nums[0])
	nd.append(nums[-1])
	for i in nums[1:-1]:
		rd.append(i)
else:
	st.append(nums[0])
	nd.append(nums[1])
	nd.append(nums[2])
	for i in nums[3:]:
		rd.append(i)
print(str(len(st)) + ' ' + ' '.join(st) + '\n' + str(len(nd)) + ' ' + ' '.join(nd) + '\n' + str(len(rd)) + ' ' + ' '.join(rd))


n = int(input())
l1 = list(map(int, input().split()))
n = []
p = []
z = []
for i in l1:
	if i < 0:
		n.append(i)
	elif i == 0:
		z.append(i)
	else:
		p.append(i)
if len(p) == 0:
	p.append(n[0])
	p.append(n[1])
	del n[0]
	del n[0]
if len(n) % 2 == 0:
	z.append(n[0])
	del n[0]
print(len(n), end=' ')
for i in n:
	print(i, end=' ')
print()
print(len(p), end=' ')
for i in p:
	print(i, end=' ')
print()
print(len(z), end=' ')
for i in z:
	print(i, end=' ')
print()


n = int(input())
a = [int(x) for x in input().split()]
s1 = []
s2 = []
s3 = []
for i in range(len(a)):
	if a[i] > 0:
		s1.append(a[i])
	if a[i] == 0:
		s2.append(a[i])
	if a[i] < 0:
		s3.append(a[i])
if len(s3) % 2 == 0:
	y = s3.pop()
	s2.append(y)
if len(s1) == 0:
	y = s3.pop()
	s1.append(y)
	y = s3.pop()
	s1.append(y)
print(len(s3), end=' ')
for i in range(len(s3)):
	print(s3[i], end=' ')
print()
print(len(s1), end=' ')
for i in range(len(s1)):
	print(s1[i], end=' ')
print()
print(len(s2), end=' ')
for i in range(len(s2)):
	print(s2[i], end=' ')
print()


n = int(input().strip())
lst = list(map(int, input().strip().split()))
zeroes = lst.count(0)
zero_lst = [0] * zeroes
plus = []
minus = []
for i in lst:
	if i > 0:
		plus.append(i)
	elif i < 0:
		minus.append(i)
lst1 = minus[0]
if len(minus) % 2 == 1:
	lst2 = minus[1:] + plus
	lst3 = zero_lst
elif len(minus) > 2:
	lst2 = minus[1:3] + plus
	lst3 = zero_lst + minus[3:]
else:
	lst2 = plus
	lst3 = zero_lst + minus[1:]
print(1, lst1)
print(len(lst2), ' '.join(map(str, lst2)))
print(len(lst3), ' '.join(map(str, lst3)))


n = int(input())
a = [int(j) for j in input().split()]
nv = []
pv = []
z = []
for k in a:
	if k > 0:
		pv.append(k)
	elif k < 0:
		nv.append(k)
	else:
		z.append(k)
if len(nv) % 2 == 0:
	h = nv[0]
	nv = nv[1:]
	z.append(h)
if len(pv) == 0:
	pv.append(nv[0])
	pv.append(nv[1])
	nv = nv[2:]
print(len(nv), *nv)
print(len(pv), *pv)
print(len(z), *z)


import sys, math
n = int(input())
a = sorted(map(int, input().split()))
b = [a.pop(0)]
c = [a.pop()] if a[-1] > 0 else [a.pop(0), a.pop(0)]
for L in (b, c, a):
	print(len(L), ' '.join(map(str, L)))


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
if arr[n - 1] > 0:
	print(1, arr[0])
	print(1, arr[n - 1])
	print(n - 2, end=' ')
	for j in range(1, n - 1):
		print(arr[j])
else:
	print(1, arr[0])
	print(2, arr[1], arr[2])
	print(n - 3, end=' ')
	for j in range(3, n):
		print(arr[j], end=' ')


n = int(input())
l = list(map(int, input().split()))
neg = []
zero = []
pos = []
for i in range(n):
	if l[i] == 0:
		zero.append(l[i])
	if l[i] > 0:
		pos.append(l[i])
	if l[i] < 0:
		neg.append(l[i])
if len(neg) % 2 == 0:
	num = neg.pop(0)
	zero.append(num)
if len(pos) == 0:
	if len(neg) > 2 and len(neg) % 2 == 1:
		n1 = neg.pop(0)
		n2 = neg.pop(0)
		pos.append(n1)
		pos.append(n2)
print(len(neg), end=' ')
for i in neg:
	print(i, end=' ')
print()
print(len(pos), end=' ')
for i in pos:
	print(i, end=' ')
print()
print(len(zero), end=' ')
for i in zero:
	print(i, end=' ')


n = int(input())
a = sorted(map(int, input().split()))
print(1, a[0])
if a[-1] <= 0:
	print(2, a[1], a[2])
	print(n - 3, *a[3:])
else:
	print(1, a[-1])
	print(n - 2, *a[1:-1])


n = int(input())
arr = list(map(int, input().split()))
pos_arr = []
neg_arr = []
s = 100000
for i in arr:
	if i > 0:
		pos_arr.append(i)
	if i < 0:
		neg_arr.append(i)
(print(1, end=' '), print(neg_arr[0]))
if len(pos_arr) > 0:
	(print(1, end=' '), print(pos_arr[0]))
	print(len(arr) - 2, end=' ')
	for i in range(1, len(neg_arr)):
		print(neg_arr[i], end=' ')
	for j in range(1, len(pos_arr)):
		print(pos_arr[j], end=' ')
	print(0)
else:
	(print(2, end=' '), print(neg_arr[1], end=' '), print(neg_arr[2]))
	print(len(arr) - 3, end=' ')
	for j in range(3, len(neg_arr)):
		print(neg_arr[j], end=' ')
	print(0)


n = int(input())
l = input().split()
l1 = []
l2 = []
l3 = []
for i in l:
	if int(i) < 0:
		l1.append(int(i))
	if int(i) > 0:
		l2.append(int(i))
	if int(i) == 0:
		l3.append(int(i))
if len(l2) == 0:
	l2.append(l1.pop())
	l2.append(l1.pop())
if len(l1) % 2 == 0:
	l3.append(l1.pop())
r1 = str(l1).strip('[').strip(']').replace(',', '')
r2 = str(l2).strip('[').strip(']').replace(',', '')
r3 = str(l3).strip('[').strip(']').replace(',', '')
print(len(l1), r1)
print(len(l2), r2)
print(len(l3), r3)


n = int(input())
lis = list(map(int, input().split()))
neg = 0
pos = 0
zrs = 0
neg_l = []
pos_l = []
zrs_l = []
for i in lis:
	if i < 0:
		neg_l.append(i)
		neg += 1
	elif i > 0:
		pos_l.append(i)
		pos += 1
	else:
		zrs_l.append(i)
		zrs += 1
if pos == 0:
	pos_l.append(neg_l[0])
	pos_l.append(neg_l[1])
	del neg_l[0]
	del neg_l[0]
	if neg % 2 == 0:
		zrs_l.append(neg_l[0])
		del neg_l[0]
elif neg % 2 == 0:
	zrs_l.append(neg_l[0])
	del neg_l[0]
print(len(neg_l), ' '.join(list(map(str, neg_l))))
print(len(pos_l), ' '.join(list(map(str, pos_l))))
print(len(zrs_l), ' '.join(list(map(str, zrs_l))))


n = int(input())
arr = list(map(int, input().split()))
positives = []
negatives = []
zero = []
for i in arr:
	if i < 0:
		negatives.append(i)
	elif i > 0:
		positives.append(i)
	else:
		zero.append(i)
print(1, negatives[0])
if len(positives) == 0:
	print(2, negatives[1], negatives[2])
	print(len(negatives[3:]) + len(zero), end=' ')
	for i in range(3, len(negatives)):
		print(negatives[i], end=' ')
	for i in zero:
		print(i, end=' ')
else:
	print(1, positives[0])
	print(len(negatives[1:]) + len(positives[1:]) + len(zero), end=' ')
	for i in range(1, len(positives)):
		print(positives[i], end=' ')
	for i in range(1, len(negatives)):
		print(negatives[i], end=' ')
	for i in zero:
		print(i, end=' ')


n = int(input())
a = list(input().split())
neg = []
zer = []
pos = []
for i in a:
	if int(i) < 0:
		neg.append(i)
	elif int(i) == 0:
		zer.append(i)
	else:
		pos.append(i)
print(1, neg[0])
neg = neg[1:]
if pos == []:
	print(2, neg[0], neg[1])
	neg = neg[2:]
else:
	print(1, pos[0])
	pos = pos[1:]
print(len(zer + neg + pos), ' '.join(zer + neg + pos))


n = int(input())
a = list(map(int, input().split()))
for x in range(n):
	if a[x] < 0:
		print(1, a[x])
		del a[x]
		break
for y in range(len(a)):
	if a[y] > 0:
		print(1, a[y])
		del a[y]
		break
else:
	print(2, end=' ')
	print(min(a), end=' ')
	a.remove(min(a))
	print(min(a))
	a.remove(min(a))
print(len(a), ' '.join(map(str, a)))


n = int(input())
l = [int(i) for i in input().split()]
pos = 0
zer = 0
neg = 0
p = []
n = []
for e in l:
	if e == 0:
		zer += 1
	elif e < 0:
		neg += 1
		n += [e]
	else:
		pos += 1
		p += [e]
print('1 ' + str(n[0]))
if pos > 0:
	print('1 ' + str(p[0]))
	print(str(zer + neg + pos - 2) + ' ')
	for e in range(1, neg):
		print(n[e], end=' ')
	for e in range(1, pos):
		print(p[e], end=' ')
else:
	print('2 ' + str(n[1]) + ' ' + str(n[2]))
	print(str(zer + neg - 3) + ' ')
	for e in range(3, neg):
		print(n[e], end=' ')
for e in range(0, zer):
	print('0 ')


n = int(input())
a = list(map(int, input().split()))
n1 = []
n2 = []
n3 = []
for i in range(n):
	if a[i] > 0:
		n2.append(a[i])
	elif a[i] < 0:
		n1.append(a[i])
	else:
		n3.append(a[i])
if len(n1) % 2 == 0:
	x = n1.pop()
	n3.append(x)
if len(n2) == 0:
	x = n1.pop()
	n2.append(x)
	x = n1.pop()
	n2.append(x)
print(len(n1), end=' ')
for i in n1:
	print(i, end=' ')
print()
print(len(n2), end=' ')
for i in n2:
	print(i, end=' ')
print()
print(len(n3), end=' ')
for i in n3:
	print(i, end=' ')
print()


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

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

def In():
	return int(input())

def func():
	pass

def main():
	n = In()
	arr = list(intArr())
	freq = {-1: [], 1: [], 0: []}
	for i in arr:
		if i == 0:
			freq[0].append(0)
		elif i < 0:
			freq[-1].append(i)
		else:
			freq[1].append(i)
	if len(freq[-1]) & 1 == 0:
		freq[0].append(freq[-1].pop())
	if len(freq[1]) == 0:
		freq[1].append(freq[-1].pop())
		freq[1].append(freq[-1].pop())
	for i in freq:
		print(len(freq[i]), *freq[i])
	return
main()


n = int(input())
l = list(map(int, input().split()))
neg = []
z = []
pos = []
for i in l:
	if i > 0:
		pos.append(i)
	elif i == 0:
		z.append(i)
	else:
		neg.append(i)
if len(pos) == 0:
	pos.append(neg[0])
	pos.append(neg[1])
	neg.remove(neg[0])
	neg.remove(neg[0])
if len(neg) % 2 == 0:
	z.append(neg[0])
	neg.remove(neg[0])
print(len(neg), end=' ')
for i in neg:
	print(i, end=' ')
print()
print(len(pos), end=' ')
for i in pos:
	print(i, end=' ')
print()
print(len(z), end=' ')
for i in z:
	print(i, end=' ')
print()


n = int(input())
numb = list(map(int, input().rstrip().split()))
minus = []
plus = []
zero = []
for i in range(n):
	if numb[i] > 0:
		plus.append(numb[i])
	elif numb[i] < 0:
		minus.append(numb[i])
	else:
		zero.append(numb[i])
if len(plus) == 0:
	plus.append(minus[0])
	plus.append(minus[1])
	del minus[0]
	del minus[0]
if len(minus) % 2 == 0:
	zero.append(minus[0])
	del minus[0]
print(len(minus), end=' ')
for i in minus:
	print(i, end=' ')
print('\n')
print(len(plus), end=' ')
for i in plus:
	print(i, end=' ')
print('\n')
print(len(zero), end=' ')
for i in zero:
	print(i, end=' ')
print('\n')


n = int(input())
a = list(map(int, input().split()))
v1 = []
v2 = []
v3 = []
for i in range(len(a)):
	if a[i] < 0:
		v1.append(a[i])
	elif a[i] > 0:
		v2.append(a[i])
	else:
		v3.append(a[i])
if len(v1) % 2 == 0:
	v3.append(v1[-1])
	v1.remove(v1[-1])
if len(v2) == 0:
	v2.append(v1[-1])
	v2.append(v1[-2])
	del v1[-1]
	del v1[-1]

def p(x):
	print(len(x), end=' ')
	for j in range(len(x)):
		print(x[j], end=' ')
	print()
p(v1)
p(v2)
p(v3)


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import log2, ceil
from bisect import bisect_right as br, bisect_left as bl
from collections import Counter as C
(n,) = I()
l = I()
l.sort()
c = 0
for i in l:
	if i < 0:
		c += 1
f = 0
print(1, l[0])
f += 1
z = sum([1 for i in l if i == 0])
if c % 2 == 0:
	f += z + 1
	k = 2
else:
	f += z
	k = 1
print(n - f, *[i for i in l[k:] if i != 0])
if c % 2 == 0:
	print(z + 1, *[0] * z, l[1])
else:
	print(z, *[0] * z)


n = int(input())
sl = list(map(int, input().split()))
s1 = []
s2 = []
s3 = []
countn = 0
tn = 0
for i in sl:
	if i < 0:
		tn += 1
for i in sl:
	if i < 0 and countn == 0:
		s1 += [str(i)]
		countn = 1
	elif i > 0 or (i < 0 and countn < 3 and (tn >= 3)):
		if i < 0 and tn >= 3 and (countn < 3):
			countn += 1
			s2 += [str(i)]
		elif i > 0:
			s2 += [str(i)]
	elif i <= 0:
		if tn >= 3 and countn > 2:
			s3 += [str(i)]
		elif tn < 3:
			s3 += [str(i)]
		elif i == 0:
			s3 += [str(i)]
print(len(s1), ' '.join(s1))
print(len(s2), ' '.join(s2))
print(len(s3), ' '.join(s3))


N = int(input())
arr = list(map(int, input().split()))
n = []
p = []
for i in arr:
	if i < 0:
		n.append(i)
	if i > 0:
		p.append(i)
if len(p) > 0:
	print(1, n.pop())
	print(len(p), *p)
	print(len(n) + 1, 0, *n)
else:
	print(1, n.pop())
	print(2, n.pop(), n.pop())
	print(N - 3, 0, *n)


n = int(input())
a = sorted([int(i) for i in input().split()])
k = 0
for i in range(n):
	if not a[i]:
		k = i
		break
if len(a[:k]) % 2:
	print(1, a[0])
	print(n - 1 - a.count(0), end=' ')
	for i in a[1:]:
		if i:
			print(i, end=' ')
	print()
	print(a.count(0), '0 ' * a.count(0))
else:
	print(1, a[0])
	print(n - 2 - a.count(0), end=' ')
	for i in a[2:]:
		if i:
			print(i, end=' ')
	print()
	print(a.count(0) + 1, a[1], '0 ' * a.count(0))


import math
n = int(input())
neg = []
negs = 0
pos = []
poss = 0
zero = []
zeros = 0
for k in input().split():
	i = int(k)
	if i < 0:
		neg.append(i)
		negs += 1
	elif i == 0:
		zero.append(i)
		zeros += 1
	else:
		pos.append(i)
		poss += 1
if negs % 2 == 0 and negs > 0:
	zero.append(neg[0])
	zeros += 1
	neg = neg[1:]
	negs -= 1
if poss == 0:
	pos = neg[:2]
	poss += 2
	neg = neg[2:]
	negs -= 2
print(negs, ' '.join(map(str, neg)))
print(poss, ' '.join(map(str, pos)))
print(zeros, ' '.join(map(str, zero)))


n = int(input())
pos = []
neg = []
zeros = []

def list_to_string(lis):
	s = ''
	for i in lis:
		s = s + str(i) + ' '
	return s
inpL = sorted(map(int, input().split()))
for inp in inpL:
	inp = int(inp)
	if inp > 0:
		pos.append(inp)
	elif inp < 0:
		neg.append(inp)
	else:
		zeros.append(inp)
if len(neg) % 2 == 0:
	zeros.append(neg[-1])
	neg.pop()
if len(pos) == 0:
	pos.append(neg[-1])
	neg.pop()
	pos.append(neg[-1])
	neg.pop()
print(str(len(neg)) + ' ' + list_to_string(neg))
print(str(len(pos)) + ' ' + list_to_string(pos))
print(str(len(zeros)) + ' ' + list_to_string(zeros))


C = 1

def main():
	n = int(input())
	l = sorted(map(int, input().split()))
	a = l.index(0)
	b = a + l.count(0)
	l1 = l[:a]
	l3 = l[a:b]
	l2 = l[b:]
	if not l2:
		l2 = l1[-2:]
		del l1[-2:]
	if not len(l1) & 1:
		l3.append(l1.pop())
	for l in (l1, l2, l3):
		print(len(l))
		print(*l)
main()


positives = []
negatives = []
zeros = []
n = int(input())
nums = [int(c) for c in input().split()]
for e in nums:
	if e > 0:
		positives.append(e)
	elif e < 0:
		negatives.append(e)
	else:
		zeros.append(e)
set1 = []
set2 = []
set3 = []
set1.append(negatives.pop())
if not positives:
	set2.append(negatives.pop())
	set2.append(negatives.pop())
else:
	set2.append(positives.pop())
set3 += zeros
set3 += positives
set3 += negatives
print(len(set1), *set1)
print(len(set2), *set2)
print(len(set3), *set3)


n = (int, input().split())
arr = list(map(int, input().split()))
a = [0] * 3
a[0] = [i for i in arr if i < 0]
a[1] = [i for i in arr if i > 0]
a[2] = [i for i in arr if i == 0]
if len(a[0]) % 2 == 0:
	a[2].append(a[0][0])
	a[0].remove(a[0][0])
if len(a[1]) == 0:
	if len(a[0]) % 2 != 0 and len(a[0]) > 2:
		a[1].append(a[0][0])
		a[0].remove(a[0][0])
		a[1].append(a[0][0])
		a[0].remove(a[0][0])
for i in a:
	_str = str(len(i))
	for j in i:
		_str += ' ' + str(j)
	print(_str)


n = int(input())
array = list(map(int, input().split()))
list1 = []
list2 = []
list3 = []
for i in range(n):
	if array[i] > 0:
		list2.append(array[i])
	if array[i] < 0:
		list1.append(array[i])
	if array[i] == 0:
		list3.append(array[i])
if len(list2) != 0:
	if len(list1) % 2 == 0:
		list3.append(list1[len(list1) - 1])
		list1.pop()
else:
	list2.append(list1[0])
	list2.append(list1[1])
	list1.pop(0)
	list1.pop(0)
	if len(list1) % 2 == 0:
		list3.append(list1[len(list1) - 1])
		list1.pop()
r1 = ''
r2 = ''
r3 = ''
for i in range(len(list1)):
	r1 += str(list1[i])
	r1 += ' '
for i in range(len(list2)):
	r2 += str(list2[i])
	r2 += ' '
for i in range(len(list3)):
	r3 += str(list3[i])
	r3 += ' '
print(str(len(list1)) + ' ' + r1)
print(str(len(list2)) + ' ' + r2)
print(str(len(list3)) + ' ' + r3)


n = int(input())
list1 = list(map(int, input().split()))
l1 = []
l2 = []
l3 = []
for i in range(n):
	if list1[i] > 0:
		l2.append(list1[i])
	elif list1[i] == 0:
		l3.append(list1[i])
	else:
		l1.append(list1[i])
if len(l2) == 0:
	l2.append(l1.pop())
	l2.append(l1.pop())
if len(l1) % 2 == 0:
	l3.append(l1.pop())
print(len(l1), *l1)
print(len(l2), *l2)
print(len(l3), *l3)


def printa(x):
	print(len(x), ' '.join([str(k) for k in x]))
n = int(input())
values = [int(k) for k in input().split()]
values.sort()
nega = []
zeros = []
posi = []
for i in values:
	if i < 0:
		nega.append(i)
	elif i == 0:
		zeros.append(i)
	else:
		posi.append(i)
if len(posi) == 0:
	posi.append(nega.pop(0))
	posi.append(nega.pop(0))
if len(nega) % 2 == 0:
	zeros.append(nega.pop(0))
printa(nega)
printa(posi)
printa(zeros)


n = int(input().strip())
original_numbers = list(map(int, input().strip().split()))
negative_numbers = [i for i in original_numbers if i < 0]
positive_numbers = [i for i in original_numbers if i > 0]
zero = [i for i in original_numbers if i == 0]
if len(negative_numbers) % 2 == 0:
	zero.append(negative_numbers[-1])
	negative_numbers.remove(negative_numbers[-1])
if len(positive_numbers) == 0:
	for i in range(2):
		positive_numbers.append(negative_numbers[-1])
		negative_numbers.remove(negative_numbers[-1])
negative_numbers = [str(i) for i in negative_numbers]
positive_numbers = [str(i) for i in positive_numbers]
zero = [str(i) for i in zero]
print(len(negative_numbers), ' '.join(negative_numbers))
print(len(positive_numbers), ' '.join(positive_numbers))
print(len(zero), ' '.join(zero))


def printResult(a):
	print(len(a), end=' ')
	for x in a:
		print(x, end=' ')
	print()
n = int(input())
a = list(map(int, input().split()))
positive = []
negative = []
zero = []
for x in a:
	if x < 0:
		negative.append(x)
		break
for x in a:
	if x > 0:
		positive.append(x)
if len(positive) == 0:
	for x in a:
		if x < 0 and x not in negative:
			positive.append(x)
			if len(positive) == 2:
				break
for x in positive:
	a.remove(x)
for x in negative:
	a.remove(x)
zero = list(a)
printResult(negative)
printResult(positive)
printResult(zero)


def count_neg(l):
	c_neg = 0
	for num in l:
		c_neg += num < 0
	return c_neg
n = int(input())
li = list(map(int, input().split()))
c = count_neg(li)
(l1, l2, l3) = ([], [], [])
for i in li:
	if i == 0:
		l3.append(i)
	elif i < 0:
		if not l1:
			l1.append(i)
			c -= 1
		elif count_neg(l2) < 2 and c >= 2:
			l2.append(i)
		else:
			l3.append(i)
	elif not l2:
		l2.append(i)
	else:
		l3.append(i)
print(len(l1), *l1)
print(len(l2), *l2)
print(len(l3), *l3)


n = int(input())
a = []
b = []
c = []
for x in input().split():
	if int(x) > 0:
		a.append(x)
	elif int(x) < 0:
		if len(c) == 0:
			c.append(x)
		else:
			b.append(x)
	else:
		b.append(x)
if len(a) == 0:
	b = sorted(b, reverse=True)
	a.append(b.pop())
	a.append(b.pop())
b = sorted(b)
print(len(c), ' '.join(c))
print(len(a), ' '.join(a))
print(len(b), ' '.join(b))


n = int(input())
a = list(map(int, input().split()))
n1 = []
n2 = []
n3 = ['0']
a.remove(0)
n4 = []
for i in a:
	m = True
	if len(n1) < 1 and i < 0:
		n1.append(str(i))
		m = False
	elif m == True and i < 0:
		n2.append(str(i))
	elif i > 0:
		n4.append(str(i))
if len(n2) == 0:
	for i in n4:
		n2.append(i)
elif len(n2) % 2 > 0:
	n3.append(n2[0])
	n2.remove(n2[0])
	for i in n4:
		n2.append(i)
else:
	for i in n4:
		n3.append(i)
print(len(n1), ' '.join(n1))
print(len(n2), ' '.join(n2))
print(len(n3), ' '.join(n3))


n = int(input())
(neg, pos, zero) = ([], [], [])
for x in input().split(' '):
	if int(x) < 0:
		neg.append(x)
	elif int(x) > 0:
		pos.append(x)
	else:
		zero.append(x)
if len(pos) == 0:
	pos.append(neg[-1])
	pos.append(neg[-2])
	neg.pop()
	neg.pop()
if len(neg) % 2 == 0:
	zero.append(neg[-1])
	neg.pop()
print(len(neg), ' '.join(neg))
print(len(pos), ' '.join(pos))
print(len(zero), ' '.join(zero))


x = int(input())
y = input().split()
a = []
b = []
c = []
for i in y:
	i = int(i)
	if i < 0:
		a.append(i)
	elif i > 0:
		b.append(i)
	elif i == 0:
		c.append(i)
if len(b) == 0:
	b.append(a[0])
	b.append(a[1])
	a.pop(0)
	a.pop(0)
if len(a) % 2 == 0:
	c.append(a[0])
	a.pop(0)
print(len(a), end=' ')
for w in a:
	print(int(w), end=' ')
print()
print(len(b), end=' ')
for x in b:
	print(int(x), end=' ')
print()
print(len(c), end=' ')
for v in c:
	print(int(v), end=' ')


n = int(input())
l = list(map(int, input().split()))
under = []
up = []
zero = []
for i in l:
	if i < 0:
		under.append(i)
	elif i == 0:
		zero.append(i)
	else:
		up.append(i)
if len(up) == 0:
	up.append(under.pop())
	up.append(under.pop())
if len(under) % 2 == 0:
	zero.append(under.pop())
print(str(len(under)) + ' ' + ' '.join(map(str, under)))
print(str(len(up)) + ' ' + ' '.join(map(str, up)))
print(str(len(zero)) + ' ' + ' '.join(map(str, zero)))


n = int(input())
mylist = list(map(int, input().split()))
mylist.sort()
list1 = [mylist[0]]
list2 = []
list3 = []
index12 = [0]
if mylist[-1] > 0:
	list2.append(mylist[n - 1])
	index12.append(n - 1)
else:
	list2.append(mylist[1])
	list2.append(mylist[2])
	index12.append(1)
	index12.append(2)
for i in range(0, n):
	if i not in index12:
		list3.append(mylist[i])

def printall(list):
	print(len(list), end=' ', flush=True)
	print(' '.join((str(x) for x in list)))
printall(list1)
printall(list2)
printall(list3)


def main():
	n = int(input())
	a = [int(i) for i in input().split()]
	ans = [[], [], []]
	neg = sum((x < 0 for x in a))
	flag = 0
	for x in a:
		if x > 0:
			ans[1].append(x)
		elif x == 0:
			ans[2].append(x)
		elif neg % 2 == 0 and (not flag):
			ans[2].append(x)
			flag = 1
		else:
			ans[0].append(x)
	if not ans[1]:
		assert len(ans[0]) >= 2
		ans[1].extend(ans[0][:2])
		ans[0] = ans[0][2:]
	for arr in ans:
		print(len(arr), *arr)
main()


n = int(input())
a = list(map(int, input().split()))
N = []
P = []
Z = []
for i in a:
	if i < 0:
		N.append(i)
	elif i > 0:
		P.append(i)
	else:
		Z.append(i)
if len(N) % 2 != 0:
	if len(N) != 1:
		P = P + N[1:]
		N = [N[0]]
elif len(P) == 0:
	P = N[1:3]
	Z = Z + N[3:]
	N = [N[0]]
else:
	Z = Z + N[1:]
	N = [N[0]]
n = list(N)
p = list(P)
z = list(Z)
print(len(n), end=' ')
for i in n:
	print(i, end=' ')
print()
print(len(p), end=' ')
for i in p:
	print(i, end=' ')
print()
print(len(z), end=' ')
for i in z:
	print(i, end=' ')


n = int(input())
a = []
b = []
c = []
d = []
mangam = []
a = list(map(int, input().split()))
countam = 0
for i in range(0, n):
	if a[i] == 0:
		d.append(a[i])
for i in range(0, n):
	if a[i] < 0:
		countam += 1
		mangam.append(a[i])
if countam % 2 == 0:
	d.append(mangam[0])
	b.append(mangam[1])
	for i in range(2, countam):
		c.append(mangam[i])
else:
	b.append(mangam[0])
	for i in range(1, countam):
		c.append(mangam[i])
for i in range(n):
	if a[i] > 0:
		c.append(a[i])
print(len(b), end=' ')
for i in range(len(b)):
	print(b[i], end=' ')
print('')
print(len(c), end=' ')
for i in range(len(c)):
	print(c[i], end=' ')
print('')
print(len(d), end=' ')
for i in range(len(d)):
	print(d[i], end=' ')


n = int(input())
arr = list(map(int, input().split()))
a_neg = []
b_pos = []
c_zero = []
d = []
for i in range(n):
	if arr[i] == 0:
		c_zero.append(arr[i])
	elif arr[i] < 0:
		a_neg.append(arr[i])
	else:
		b_pos.append(arr[i])
if len(a_neg) != 0:
	if len(a_neg) % 2 == 0:
		e = a_neg.pop(1)
		c_zero.append(e)
if len(b_pos) == 0:
	b_pos.append(a_neg[0])
	a_neg.pop(0)
	b_pos.append(a_neg[1])
	a_neg.pop(1)
print(len(a_neg), end=' ')
for i in a_neg:
	print(i, end=' ')
print('\n', end='')
print(len(b_pos), end=' ')
for i in b_pos:
	print(i, end=' ')
print('\n', end='')
print(len(c_zero), end=' ')
for i in c_zero:
	print(i, end=' ')


import sys
import math
from sys import stdin, stdout

def sieve(N):
	primeNumbers = [True] * (N + 1)
	primeNumbers[0] = False
	primeNumbers[1] = False
	i = 2
	while i * i <= N:
		j = i
		if primeNumbers[j]:
			while j * i <= N:
				primeNumbers[j * i] = False
				j += 1
		i += 1
	return primeNumbers

def getPrime(N):
	primes = sieve(N)
	result = []
	for i in range(len(primes)):
		if primes[i]:
			result.append(i)
	return result

def factor(N):
	factors = []
	i = 1
	while i * i <= N:
		if N % i == 0:
			factors.append(i)
			if i != N // i:
				factors.append(N // i)
		i += 1
	return sorted(factors)

def reduceB(b):
	mod = 0
	for i in range(0, len(b)):
		mod = (mod * 10 + ord(b[i])) % 1000000007
	return mod

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

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

def get_int():
	return int(input())

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

def get_list_of_list(n):
	return [list(map(int, sys.stdin.readline().strip().split())) for _ in range(n)]

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

def main():
	n = int(input())
	arr = get_ints_in_list()
	arr.sort()
	print(1, arr[0])
	if arr[1] < 0 and arr[2] < 0:
		print(2, arr[1], arr[2])
		res = []
		for i in range(3, n):
			res.append(arr[i])
		print(n - 3, end=' ')
		for i in range(0, len(res)):
			print(res[i], end=' ')
		print()
	else:
		print(1, arr[n - 1])
		res = []
		for i in range(1, n - 1):
			res.append(arr[i])
		print(n - 2, end=' ')
		for i in range(0, len(res)):
			print(res[i], end=' ')
		print()
main()


n = int(input())
a = list(map(int, input().split()))
neg = []
pos = []
zero = []
(cn, cp, cz) = (0, 0, 0)
for i in a:
	if i < 0:
		cn += 1
		neg.append(i)
	elif i > 0:
		cp += 1
		pos.append(i)
	else:
		cz += 1
		zero.append(i)
if cn % 2 == 0:
	zero.append(neg[cn - 1])
	neg.remove(neg[cn - 1])
	cn -= 1
	cz += 1
if cp == 0:
	pos.append(neg[cn - 1])
	pos.append(neg[cn - 2])
	neg.remove(neg[cn - 1])
	neg.remove(neg[cn - 2])
	cn = cn - 2
	cp = cp + 2
l = ' '
print(cn, ' '.join(map(str, neg)))
print(cp, ' '.join(map(str, pos)))
print(cz, ' '.join(map(str, zero)))


import sys
from functools import reduce
from collections import Counter
import time
import datetime
from math import sqrt, gcd

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

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

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

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

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

def matip(n, m):
	lst = []
	for i in range(n):
		arr = lip()
		lst.append(arr)
	return lst

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

def minJumps(arr, n):
	jumps = [0 for i in range(n)]
	if n == 0 or arr[0] == 0:
		return float('inf')
	jumps[0] = 0
	for i in range(1, n):
		jumps[i] = float('inf')
		for j in range(i):
			if i <= j + arr[j] and jumps[j] != float('inf'):
				jumps[i] = min(jumps[i], jumps[j] + 1)
				break
	return jumps[n - 1]

def dic(arr):
	return Counter(arr)

def check_prime(n):
	if n < 2:
		return False
	for i in range(2, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return False
	return True
n = ip()
arr = lip()
arr.sort()
first = arr[0]
last = arr[-1]
print(1, first)
if last == 0:
	print(2, arr[-2], arr[-3])
	print(n - 3, *arr[1:-3], arr[-1])
else:
	print(1, last)
	print(n - 2, *arr[1:-1])


def array(arr):
	set1 = []
	set2 = []
	set3 = []
	for i in arr:
		if i > 0:
			set2.append(i)
		elif i == 0:
			set3.append(i)
		else:
			set1.append(i)
	if len(set1) % 2 == 0:
		set3.append(set1.pop())
	if len(set2) == 0:
		set2.append(set1.pop())
		set2.append(set1.pop())
	print(len(set1), *set1)
	print(len(set2), *set2)
	print(len(set3), *set3)
input()
array(list(map(int, input().split())))


N = int(input())
A = list(map(int, input().split()))
b1 = []
b2 = []
b3 = []
cntpol = False
pol = 0
otr = 0
cntotr = False
for i in range(0, N):
	if A[i] > 0:
		pol += 1
curpol = 0
if pol == 0:
	for i in range(0, N):
		if A[i] < 0:
			if curpol < 2:
				b1.append(A[i])
			elif curpol > 2:
				b2.append(A[i])
			else:
				b3.append(A[i])
			curpol += 1
		if A[i] == 0:
			b2.append(A[i])
else:
	for i in range(0, N):
		if A[i] == 0:
			b2.append(A[i])
		elif A[i] > 0:
			if cntpol:
				b2.append(A[i])
			else:
				b1.append(A[i])
				cntpol = True
		elif cntotr:
			b2.append(A[i])
		else:
			b3.append(A[i])
			cntotr = True
print(len(b3), end=' ')
for i in range(0, len(b3)):
	print(b3[i], end=' ')
print()
print(len(b1), end=' ')
for i in range(0, len(b1)):
	print(b1[i], end=' ')
print()
print(len(b2), end=' ')
for i in range(0, len(b2)):
	print(b2[i], end=' ')


n = int(input())
a = list(map(int, input().split()))
pos = []
m0 = []
neg = []
for el in a:
	if el == 0:
		m0.append(0)
		continue
	if el < 0:
		neg.append(el)
	else:
		pos.append(el)
if len(pos) == 0:
	pos.append(neg.pop())
	pos.append(neg.pop())
if len(neg) % 2 == 0:
	m0.append(neg.pop())
print(len(neg), end=' ')
for el in neg:
	print(el, end=' ')
print()
print(len(pos), end=' ')
for el in pos:
	print(el, end=' ')
print()
print(len(m0), end=' ')
for el in m0:
	print(el, end=' ')


length = int(input())
arr = list(map(int, input().split()))
pos = []
neg = []
zeros = []
for num in arr:
	if num > 0:
		pos.append(num)
	elif num < 0:
		neg.append(num)
	else:
		zeros.append(num)
if len(pos) == 0:
	pos.append(neg.pop())
	pos.append(neg.pop())
if len(neg) % 2 == 0:
	zeros.append(neg.pop())
print(len(neg), *neg)
print(len(pos), *pos)
print(len(zeros), *zeros)


n = int(input())
l_i = list(map(int, input().split()))
c_n = None
l_n = set()
l_p = set()
l_0 = set()
for i in l_i:
	if i < 0:
		if i not in l_n and i not in l_p:
			if len(l_n) != 1:
				l_n.add(i)
			elif not c_n:
				c_n = i
			elif i != c_n:
				l_p.add(c_n)
				l_p.add(i)
				c_n = None
	elif i > 0:
		l_p.add(i)
	else:
		l_0.add(i)
print(str(len(l_n)) + ' ' + ' '.join((str(x) for x in l_n)))
print(str(len(l_p)) + ' ' + ' '.join((str(x) for x in l_p)))
print(str(len(l_0) + (1 if c_n else 0)) + ' 0' + ('' if not c_n else ' %d' % c_n))


n = int(input())
a = list(map(int, input().split()))
countOdd = 0
s1 = []
s2 = []
s3 = []
for i in a:
	if i < 0:
		countOdd += 1
if countOdd == 1:
	for i in a:
		if i < 0:
			s1.append(i)
		elif i == 0:
			s3.append(i)
		else:
			s2.append(i)
elif countOdd == 2:
	for i in a:
		if i < 0:
			if len(s1) == 0:
				s1.append(i)
			else:
				s3.append(i)
		elif i == 0:
			s3.append(i)
		else:
			s2.append(i)
elif countOdd > 2:
	for i in a:
		if i < 0:
			if len(s1) == 0:
				s1.append(i)
			elif len(s2) < 2:
				s2.append(i)
			else:
				s3.append(i)
		else:
			s3.append(i)

def printS(s):
	print(len(s), end=' ')
	for i in s:
		print(i, end=' ')
	print()
printS(s1)
printS(s2)
printS(s3)


n = int(input())
num = [int(i) for i in input().split()]
pn = [0] * n
for i in range(n):
	if num[i] > 0:
		pn[i] = 1
	elif num[i] < 0:
		pn[i] = -1
s1 = -1
for i in range(n):
	if pn[i] == -1:
		s1 = i
		break
for i in range(n):
	if pn[i] == 1:
		s2 = i
		break
else:
	(cnt, s21, s22) = (0, 0, 0)
	for j in range(n):
		if pn[j] == -1 and j != s1:
			cnt += 1
			if cnt == 1:
				s21 = j
			else:
				s22 = j
				break
	print('1 %d' % num[s1])
	print('2 {} {}'.format(num[s21], num[s22]))
	print(n - 3, end=' ')
	for j in range(n):
		if j not in (s1, s21, s22):
			print(num[j], end=' ')
	exit(0)
	pass
print('1 %d' % num[s1])
print('1 %d' % num[s2])
print(n - 2, end=' ')
for i in range(n):
	if i not in (s1, s2):
		print(num[i], end=' ')


num = int(input())
nums = input().split(' ')
numsSorted = [[], 0, []]
neg = ''
pos = ''
for x in nums:
	if int(x) < 0:
		numsSorted[0].append(int(x))
	elif int(x) > 0:
		numsSorted[2].append(int(x))
	else:
		numsSorted[1] += 1
if len(numsSorted[2]) == 0:
	numsSorted[2].append(numsSorted[0][0])
	numsSorted[2].append(numsSorted[0][1])
	del numsSorted[0][0]
	del numsSorted[0][0]
for x in numsSorted[2]:
	pos += str(x) + ' '
zeros = ''
for x in range(numsSorted[1]):
	zeros += '0 '
if len(numsSorted[0]) % 2 == 0:
	for x in numsSorted[0][1:]:
		neg += str(x) + ' '
	print(str(len(numsSorted[0]) - 1) + ' ' + str(neg))
	print(str(len(numsSorted[2])) + ' ' + str(pos))
	print(str(numsSorted[1] + 1) + ' ' + zeros + str(numsSorted[0][0]))
else:
	for x in numsSorted[0]:
		neg += str(x) + ' '
	print(str(len(numsSorted[0])) + ' ' + str(neg))
	print(str(len(numsSorted[2])) + ' ' + str(pos))
	print(str(numsSorted[1]) + ' ' + zeros)


def tich_arr(arr):
	kq = 1
	for i in range(0, len(arr)):
		kq *= arr[i]
	return kq
n = int(input())
arr = list(map(int, input().split()))
lonhon0 = []
nhohon0 = []
bang0 = []
for i in range(0, n):
	if len(nhohon0) == 0 and arr[i] != 0:
		nhohon0.append(arr[i])
		del arr[i]
		break
for i in range(0, n - 1):
	if len(lonhon0) == 0 and arr[i] > 0 and (arr[i] != nhohon0[0]):
		lonhon0.append(arr[i])
		del arr[i]
		break
if len(lonhon0) == 0:
	for i in range(0, n):
		if len(lonhon0) == 0 and arr[i] != 0 and (arr[i] != nhohon0[0]):
			lonhon0.append(arr[i])
			del arr[i]
			break
for i in range(0, n):
	if arr[i] == 0:
		bang0.append(arr[i])
		del arr[i]
		break
for i in range(0, len(arr)):
	if arr[i] * tich_arr(nhohon0) < 0:
		nhohon0.append(arr[i])
	elif arr[i] * tich_arr(lonhon0) > 0:
		lonhon0.append(arr[i])
	else:
		bang0.append(arr[i])
print(len(nhohon0), end=' ')
for i in range(0, len(nhohon0)):
	print(nhohon0[i], end=' ')
print(end='\n')
print(len(lonhon0), end=' ')
for i in range(0, len(lonhon0)):
	print(lonhon0[i], end=' ')
print(end='\n')
print(len(bang0), end=' ')
for i in range(0, len(bang0)):
	print(bang0[i], end=' ')


n = int(input())
A = [int(x) for x in input().split()]
PosA = []
NegA = []
ZeroA = []
for i in A:
	if i > 0:
		PosA.append(i)
	elif i < 0:
		NegA.append(i)
	else:
		ZeroA.append(i)
if len(PosA) == 0:
	PosA.append(NegA.pop(-1))
	PosA.append(NegA.pop(-1))
if len(NegA) % 2 == 0:
	ZeroA.append(NegA.pop(-1))
print(len(NegA), end=' ')
for i in NegA:
	print(i, end=' ')
print()
print(len(PosA), end=' ')
for i in PosA:
	print(i, end=' ')
print()
print(len(ZeroA), end=' ')
for i in ZeroA:
	print(i, end=' ')
print()


n = int(input())
inSet = input().split()
for i in range(len(inSet)):
	inSet[i] = int(inSet[i])
(negSet, posSet, zeroSet) = ([], [], [])
for elem in inSet:
	if elem < 0:
		negSet.append(elem)
	elif elem == 0:
		zeroSet.append(elem)
	else:
		posSet.append(elem)
if len(negSet) % 2 == 0:
	zeroSet.append(negSet.pop())
if len(posSet) == 0:
	posSet.append(negSet.pop())
	posSet.append(negSet.pop())
print(len(negSet), end=' ')
for elem in negSet:
	print(elem, end=' ')
print()
print(len(posSet), end=' ')
for elem in posSet:
	print(elem, end=' ')
print()
print(len(zeroSet), end=' ')
for elem in zeroSet:
	print(elem, end=' ')


neg = []
pos = []
input()
numbers = list(map(int, input().split()))
for num in numbers:
	if num < 0:
		neg.append(num)
	elif num > 0:
		pos.append(num)
res_pos = []
res_neg = []
res_zer = [0]
if len(pos) == 0:
	res_pos.append(neg[0])
	res_pos.append(neg[1])
	res_neg.append(neg[2])
	for num in neg[3:]:
		res_zer.append(num)
else:
	res_pos.append(pos[0])
	for num in pos[1:]:
		res_zer.append(num)
	res_neg.append(neg[0])
	for num in neg[1:]:
		res_zer.append(num)
print(len(res_neg), end=' ')
for num in res_neg:
	print(num, end=' ')
print('')
print(len(res_pos), end=' ')
for num in res_pos:
	print(num, end=' ')
print('')
print(len(res_zer), end=' ')
for num in res_zer:
	print(num, end=' ')


el = int(input())
ar = []
ar2 = []
ar3 = []
neg = []
for i in input().split(' '):
	temp = int(i)
	if len(ar) == 0 and temp < 0:
		ar.append(temp)
	elif len(ar2) == 0 and temp > 0:
		ar2.append(temp)
	elif len(neg) < 2 and temp < 0:
		neg.append(temp)
	else:
		ar3.append(temp)
print(len(ar), *ar)
if len(ar2) == 0:
	print(len(neg), *neg)
	print(len(ar3), *ar3)
else:
	print(len(ar2), *ar2)
	print(len(ar3) + len(neg), *ar3, *neg)


n = int(input())
(neg, pos, z) = ([], [], 0)
for i in map(int, input().split()):
	if i < 0:
		neg.append(i)
	elif i > 0:
		pos.append(i)
	else:
		z += 1
print(1, neg.pop(0))
if pos:
	print(1, pos.pop(0))
	print(n - 2, *pos + neg + [0] * z)
else:
	print(2, neg.pop(0), neg.pop(0))
	print(n - 3, *pos + neg + [0] * z)


n = int(input())
v = list(map(int, input().split()))
negative = []
zero = 0
for i in range(n):
	if v[i] < 0:
		negative.append(i)
	elif v[i] == 0:
		zero = i
print(1, v[negative[0]], sep=' ', end='\n')
idx1 = -1
idx2 = -1
if len(negative) > 2:
	print(2, v[negative[1]], v[negative[2]], sep=' ', end='\n')
	idx1 = negative[1]
	idx2 = negative[2]
else:
	for i in range(n):
		if v[i] > 0:
			idx1 = i
			print(1, v[i], sep=' ', end='\n')
			break
ans = []
for i in range(n):
	if i != idx1 and i != idx2 and (i != negative[0]):
		ans.append(v[i])
print(len(ans), end=' ')
for i in ans:
	print(i, end=' ')


size = int(input())
s = [int(i) for i in input().split()]
neg = []
pos = []
zero = []
for i in range(size):
	if s[i] < 0:
		neg.append(str(s[i]))
	elif s[i] > 0:
		pos.append(str(s[i]))
	else:
		zero.append(str(s[i]))
if len(pos) == 0:
	for i in range(2):
		pos.append(neg[len(neg) - 1])
		neg.remove(neg[len(neg) - 1])
if len(neg) % 2 == 0:
	zero.append(neg[len(neg) - 1])
	neg.remove(neg[len(neg) - 1])
print(str(len(neg)) + ' ' + ' '.join(neg))
print(str(len(pos)) + ' ' + ' '.join(pos))
print(str(len(zero)) + ' ' + ' '.join(zero))


s = int(input())
t = input()
i = t.split(' ')
inpu = [int(ko) for ko in i]
pos = []
neg = []
zero = []
for q in inpu:
	if q == 0:
		zero.append(q)
	elif q < 0:
		neg.append(q)
	else:
		pos.append(q)
if len(pos) == 0:
	x = neg.pop()
	pos.append(x)
	x = neg.pop()
	pos.append(x)
if len(neg) % 2 == 0:
	x = neg.pop()
	zero.append(x)
ans = str(len(neg)) + ' ' + ' '.join((str(n) for n in neg))
print(ans)
ans = str(len(pos)) + ' ' + ' '.join((str(n) for n in pos))
print(ans)
ans = str(len(zero)) + ' ' + ' '.join((str(n) for n in zero))
print(ans)


n = int(input())
line = list(map(int, input().split()))
lo = []
up = []
z0 = []
neg = []
for k in line:
	if k == 0:
		z0.append(k)
	elif k > 0:
		up.append(k)
	else:
		neg.append(k)
if len(neg) % 2 == 0:
	z0.append(neg[0])
	neg.pop(0)
lo = neg
if len(up) == 0:
	up.append(lo[0])
	up.append(lo[1])
	lo.pop(0)
	lo.pop(0)
lostr = str(len(lo)) + ' '
for k in lo:
	lostr = lostr + str(k) + ' '
print(lostr[:-1])
upstr = str(len(up)) + ' '
for k in up:
	upstr = upstr + str(k) + ' '
print(upstr[:-1])
zstr = str(len(z0)) + ' '
for k in z0:
	zstr = zstr + str(k) + ' '
print(zstr[:-1])


n = int(input())
a = [int(i) for i in input().split()]
count = 0
a.sort()
ans1 = []
ans2 = []
ans3 = []
countp = 0
for i in range(0, n):
	if a[i] < 0:
		count += 1
	elif a[i] > 0:
		countp += 1
j = 0
for i in range(0, n):
	if i == 0:
		ans1.append(a[i])
	elif countp == 0 and j < 2:
		j += 1
		ans2.append(a[i])
	elif len(ans2) == 0 and a[i] > 0:
		ans2.append(a[i])
	else:
		ans3.append(a[i])
print(len(ans1), *ans1)
print(len(ans2), *ans2)
print(len(ans3), *ans3)


n = int(input())
l = [int(x) for x in input().split()]
a = [x for x in l if x < 0]
b = [x for x in l if x > 0]
c = [x for x in l if x == 0]
if len(b) == 0:
	(b, a) = (a[:2], a[2:])
c += a[1:]
a = a[0]
print(1, a)
print(len(b), ' '.join((str(x) for x in b)))
print(len(c), ' '.join((str(x) for x in c)))


import os
import sys
from math import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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 value():
	return map(int, input().split())

def array():
	return [int(i) for i in input().split()]
n = int(input())
a = list(map(int, input().split()))
b = []
c = []
d = []
t = 0
q = 0
for i in a:
	if i > 0:
		b.append(i)
	elif i == 0:
		c.append(0)
	else:
		d.append(i)
		q += 1
if b == []:
	b = [d[0], d[1]]
	d.remove(d[0])
	d.remove(d[0])
if q % 2 == 0:
	c.append(d[0])
	d.remove(d[0])
print(len(d), end=' ')
for i in d:
	print(i, end=' ')
print()
print(len(b), end=' ')
for i in b:
	print(i, end=' ')
print()
print(len(c), end=' ')
for i in c:
	print(i, end=' ')


input()
c = sorted(map(int, input().split()))
print(1, c.pop(0), '\n%s' % ('1 ' + str(c.pop(-1)) if c[-1] > 0 else '2 ' + str(c.pop(0)) + ' ' + str(c.pop(0))), '\n' + str(len(c)) + ' ' + ' '.join((str(x) for x in c)))


n = int(input())
a = list(map(int, input().split()))
b = 0
d = 0
e = 0
o = 0
g = []
h = []
m = []
for i in range(n):
	if a[i] < 0:
		b += 1
	elif a[i] > 0:
		d += 1
	else:
		e += 1
for i in range(n):
	if b % 2 == 1:
		if a[i] < 0 and len(g) == 0:
			g.append(a[i])
		elif a[i] > 0 or a[i] < 0:
			h.append(a[i])
		else:
			m.append(a[i])
	elif b % 2 == 0:
		if a[i] < 0 and len(g) == 0:
			g.append(a[i])
		elif a[i] < 0:
			if d == 0:
				h.append(a[i])
			else:
				m.append(a[i])
		elif a[i] > 0:
			h.append(a[i])
		else:
			m.append(a[i])
if d == 0 and len(h) % 2 != 0:
	o = h.pop()
	m.append(o)
print(len(g), *g)
print(len(h), *h)
print(len(m), *m)


input()
a = sorted(map(int, input().split()))
b = [a.pop(0)]
c = a[-1] > 0 and [a.pop()] or [a.pop(0), a.pop(0)]
for l in (b, c, a):
	print(len(l), *l)


n = int(input())
l = list(map(int, input().split()))
pos = 0
for i in range(0, n):
	if l[i] > 0:
		pos = pos + 1
l1 = []
l2 = []
l3 = []
if pos > 0:
	for i in range(0, n):
		if l[i] > 0 and len(l2) < 1:
			l2.append(l[i])
		elif l[i] < 0 and len(l1) < 1:
			l1.append(l[i])
		else:
			l3.append(l[i])
else:
	for i in range(0, n):
		if l[i] != 0 and len(l2) < 2:
			l2.append(l[i])
		elif l[i] != 0 and len(l1) < 1:
			l1.append(l[i])
		else:
			l3.append(l[i])
print(len(l1), end=' ')
for i in range(0, len(l1)):
	print(l1[i], end=' ')
print()
print(len(l2), end=' ')
for i in range(0, len(l2)):
	print(l2[i], end=' ')
print()
print(len(l3), end=' ')
for i in range(0, len(l3)):
	print(l3[i], end=' ')


import math

def fact(n):
	ans = 1
	for i in range(2, n + 1):
		ans *= i
	return ans

def comb(n, c):
	return fact(n) // (fact(n - c) * c)
n = int(input())
nums = sorted(list(map(int, input().split())))
pos = []
neg = []
s3 = ['0']
for i in range(n):
	if nums[i] < 0:
		neg.append(str(nums[i]))
	elif nums[i] > 0:
		pos.append(str(nums[i]))
if len(neg) % 2 == 0:
	if pos:
		s1 = [neg[0]]
		s2 = [pos[0]]
		s3 += pos[1:] + neg[1:]
	else:
		s1 = [neg[0]]
		s2 = neg[1:3]
		if neg[3:]:
			s3 += neg[3:]
else:
	s1 = [neg[0]]
	if not pos:
		s2 = neg[1:3]
		s3 += neg[3:]
	elif pos:
		s2 = pos
		if neg[1:]:
			s3 += neg[1:]
print(len(s1), ' '.join(s1))
print(len(s2), ' '.join(s2))
print(len(s3), ' '.join(s3))


n = int(input())
li = list(map(int, input().strip().split()))
li.sort()
p = li.index(0)
if p == n - 1:
	if n % 2 != 0:
		set1 = [li[p - 1]]
		set2 = [0, li[p - 2]]
		set3 = li[:p - 2]
	else:
		set1 = [li[p - 1]]
		set2 = [0]
		set3 = li[:p - 1]
else:
	set1 = [li[p - 1]]
	set2 = [0] + li[:p - 1]
	set3 = li[p + 1:]
print(len(set1), end=' ')
for i in set1:
	print(i, end=' ')
print()
print(len(set3), end=' ')
for i in set3:
	print(i, end=' ')
print()
print(len(set2), end=' ')
for i in set2:
	print(i, end=' ')


n = int(input())
li = list(map(int, input().rstrip().split()))
a = []
b = []
c = []
negatives = []
neg = 0
pos = 0
zero = 0
for i in li:
	if i == 0:
		zero += 1
		c += [0]
	elif i < 0:
		neg += 1
		if neg == 1:
			a += [i]
		else:
			negatives += [i]
	else:
		pos += 1
		b += [i]
num = 0
if neg % 2 == 1 and neg > 2:
	for x in negatives:
		b += [x]
elif neg % 2 == 0:
	for x in negatives:
		if num == 0:
			c += [x]
			num = 1
		else:
			b += [x]
print(len(a), end=' ')
for i in a:
	print(i, end=' ')
print()
print(len(b), end=' ')
for i in b:
	print(i, end=' ')
print()
print(len(c), end=' ')
for i in c:
	print(i, end=' ')
print()


n = int(input())
a = [int(i) for i in input().split()]
for i in a:
	if i < 0:
		print(1, i)
		a.remove(i)
		break
neg = []
for i in a:
	if i < 0:
		neg.append(i)
		if len(neg) == 2:
			a.remove(neg[0])
			a.remove(neg[1])
			print(2, ' '.join((str(i) for i in neg)))
			break
	if i > 0:
		print(1, i)
		a.remove(i)
		break
print(len(a), ' '.join((str(i) for i in a)))


input()
zero = list(map(int, input().split()))
zero.sort()
neg = [zero.pop(0)]
pos = zero[-1] > 0 and [zero.pop()] or [zero.pop(0), zero.pop(0)]
for x in (neg, pos, zero):
	print(len(x), ' '.join(map(str, x)))


t = int(input())
arr = list(map(int, input().split()))
n = []
p = []
z = []
cnt = 0
for i in range(t):
	if arr[i] < 0:
		n.append(arr[i])
	elif arr[i] > 0:
		p.append(arr[i])
	else:
		cnt += 1
if len(n) % 2 == 0 and len(n) > 0:
	f = n[0]
	n = n[1:]
	z.append(f)
if len(n) > 2 and len(p) == 0:
	p.append(n[0])
	p.append(n[1])
	n = n[2:]
z = z + [0] * cnt
print(len(n), *n)
print(len(p), *p)
print(len(z), *z)


def printArr(a):
	print(len(a), end=' ')
	for x in a:
		print(x, end=' ')
	print()
n = int(input())
a = list(map(int, input().split()))
neg = [x for x in a if x < 0]
pos = [x for x in a if x > 0]
if len(pos) == 0:
	pos = [neg.pop(), neg.pop()]
neg_new = [neg.pop()]
zero = neg + [0]
printArr(neg_new)
printArr(pos)
printArr(zero)


n = int(input())
arr = list(map(int, input().split()))
neg = [i for i in arr if i < 0]
zero = [0] * arr.count(0)
pos = [i for i in arr if i > 0]
if len(pos) == 0:
	pos.append(neg[0])
	pos.append(neg[1])
	neg.remove(neg[0])
	neg.remove(neg[0])
if len(neg) % 2 == 0:
	zero.append(neg[0])
	neg.remove(neg[0])
print(len(neg), *neg)
print(len(pos), *pos)
print(len(zero), *zero)


n = int(input())
array = list(map(int, input().split()))
neg = []
pos = []
zer = []
flag = 0
for i in range(n):
	if array[i] < 0:
		flag += 1
		neg.append(array[i])
	elif array[i] == 0:
		zer.append(array[i])
	elif array[i] > 0:
		pos.append(array[i])
if flag % 2 == 0 and flag > 1:
	zer.append(neg.pop(0))
	for i in neg[1:]:
		pos.append(i)
	neg = [neg[0]]
elif flag % 2 != 0 and flag > 1:
	for i in neg[1:]:
		pos.append(i)
	neg = [neg[0]]
for i in (neg, pos, zer):
	print(len(i), *i)


ll = lambda : map(int, input().split())
t = lambda : int(input())
ss = lambda : input()
lx = lambda x: map(int, input().split(x))
from math import log10, log2, ceil, factorial as fac, gcd

def f():
	n = t()
	l = list(ll())
	(n1, n2, n3) = ([], [], [])
	ps = []
	qs = []
	for i in range(n):
		if l[i] < 0:
			ps.append(l[i])
		elif l[i] == 0:
			n3.append(0)
		else:
			qs.append(l[i])
	if len(ps) >= 3:
		if len(qs) == 0:
			qs.append(ps.pop())
			qs.append(ps.pop())
	if len(ps) % 2 == 0:
		n3.append(ps.pop())
	print(len(ps), *ps)
	print(len(qs), *qs)
	print(len(n3), *n3)
f()


n = int(input())
l = list(map(int, input().split()))
l1 = []
l2 = []
l3 = []
l3 = [0 for i in range(l.count(0))]
for i in range(n):
	if l[i] > 0:
		l2.append(l[i])
	if l[i] < 0:
		l1.append(l[i])
if len(l1) % 2 == 0:
	l3.append(l1[0])
	del l1[0]
if len(l2) == 0:
	l2.append(l1[0])
	l2.append(l1[1])
	del l1[1]
	del l1[0]
print(len(l1), *l1)
print(len(l2), *l2)
print(len(l3), *l3)


num_of_nums = int(input())
nums = sorted(list(map(int, input().split())))
list_1 = []
list_2 = []
list_3 = []
if nums[-1] > 0:
	list_2.append(nums[-1])
	list_1.append(nums[0])
	list_3 = nums[1:-1]
	list_3.remove(0)
	list_3.append(0)
	print(len(list_1), *list_1)
	print(len(list_2), *list_2)
	print(len(list_3), *list_3)
else:
	list_2.append(nums[0])
	list_2.append(nums[1])
	list_1.append(nums[2])
	list_3 = nums[3:]
	print(len(list_1), *list_1)
	print(len(list_2), *list_2)
	print(len(list_3), *list_3)


n = int(input())
a = list(map(int, input().split(' ')))
a.sort()
zs = a.index(0)
zl = len(a) - a[::-1].index(0) - 1
if zs % 2 == 0:
	neg = a[0:zs - 1]
	zero = a[zs - 1:zl + 1]
	pos = a[zl + 1:]
else:
	neg = a[0:zs]
	zero = a[zs:zl + 1]
	pos = a[zl + 1:]
if len(pos) == 0 and len(neg) >= 3:
	pos = neg[len(neg) - 2:len(neg)]
	neg = neg[0:len(neg) - 2]
print(len(neg), end=' ')
print(*neg)
print(len(pos), end=' ')
print(*pos)
print(len(zero), end=' ')
print(*zero)


n = int(input())
l = sorted(map(int, input().split()))
print(1, l[0])
if l[-1]:
	print(1, l[-1])
	print(n - 2, ' '.join(map(str, l[1:-1])))
else:
	print(2, l[1], l[2])
	print(n - 3, ' '.join(map(str, l[3:])))


n = int(input())
nums = list(map(int, input().split()))
nums.sort()
negatives = nums.index(0)
positives = nums[::-1].index(0)
print(1, nums[0])
if positives == 0:
	print(2, nums[1], nums[2])
	print(n - 3, end=' ')
	for i in range(3, n):
		print(nums[i], end=' ')
	print()
else:
	print(1, nums[-1])
	print(n - 2, end=' ')
	for i in range(1, n - 1):
		print(nums[i], end=' ')
	print()


from sys import stdin, stdout
ii1 = lambda : int(stdin.readline())
is1 = lambda : stdin.readline()
iia = lambda : map(int, stdin.readline().split())
isa = lambda : stdin.readline().split()
n = ii1()
arr = sorted(iia())
d = {'n': [], 'z': [], 'p': []}
temp = []
for i in arr:
	if i < 0:
		if len(d['n']) == 0:
			d['n'].append(i)
		elif len(temp) < 2:
			temp.append(i)
		else:
			d['z'].append(i)
	elif i > 0 and len(d['p']) < 2:
		d['p'].append(i)
	else:
		d['z'].append(i)
if len(temp) == 2:
	d['p'].extend(temp)
else:
	d['z'].extend(temp)
print(len(d['n']), *d['n'])
print(len(d['p']), *d['p'])
print(len(d['z']), *d['z'])


n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
neg = 0
pos = 0
zer = 0
a1 = []
a2 = []
a3 = []
for i in a:
	if i < 0:
		if neg == 0:
			a1.append(i)
			neg += 1
		elif pos < 2:
			a2.append(i)
			pos += 1
		else:
			a3.append(i)
			zer += 1
	elif i > 0:
		a2.append(i)
		pos += 1
	else:
		a3.append(i)
		zer += 1
print(neg, ' '.join([str(i) for i in a1]))
print(pos, ' '.join([str(i) for i in a2]))
print(zer, ' '.join([str(i) for i in a3]))


n = int(input())
arr = list(map(int, input().split()))
ar1 = []
ar2 = []
ar3 = []
for i in range(n):
	if arr[i] > 0:
		ar2.append(arr[i])
	elif arr[i] < 0:
		ar1.append(arr[i])
	else:
		ar3.append(arr[i])
l1 = len(ar1)
l2 = len(ar2)
l3 = len(ar3)
if l2 == 0:
	ar2.append(ar1[-1])
	del ar1[-1]
	ar2.append(ar1[-1])
	del ar1[-1]
	l2 += 2
	l1 -= 2
if l1 % 2 == 0:
	ar3.append(ar1[-1])
	del ar1[-1]
	l1 -= 1
	l3 += 1
print(l1, end=' ')
for i in ar1:
	print(i, end=' ')
print()
print(l2, end=' ')
for i in ar2:
	print(i, end=' ')
print()
print(l3, end=' ')
for i in ar3:
	print(i, end=' ')
print()


def negPosZeroSplit():
	nInts = int(input())
	elems = [int(k) for k in input().split()]
	(set1, set2, set3) = ([], [], [])
	for i in range(nInts):
		if elems[i] < 0:
			set1.append(elems[i])
		elif elems[i] > 0:
			set2.append(elems[i])
		else:
			set3.append(elems[i])
	if len(set1) % 2 == 0:
		set3.append(set1.pop())
	if len(set2) == 0:
		set2.append(set1.pop())
		set2.append(set1.pop())
	print(makeRetString(set1))
	print(makeRetString(set2))
	print(makeRetString(set3))

def makeRetString(lst):
	ret = str(len(lst))
	for elem in lst:
		ret += ' ' + str(elem)
	return ret
negPosZeroSplit()


n = int(input())
s = [int(i) for i in input().split()]
(ne, po) = ([], [])
d = []
for i in s:
	if i > 0:
		po.append(i)
	elif i < 0:
		ne.append(i)
if po:
	d = po[1:] + ne[1:] + [0]
	po = [po[0]]
	ne = [ne[0]]
else:
	d = ne[3:] + [0]
	po = ne[0:2]
	ne = [ne[2]]
print(len(ne), *ne)
print(len(po), *po)
print(len(d), *d)


n = int(input())
array = input().split(' ')
for i in range(n):
	array[i] = int(array[i])
array.sort()
sets = [[array[0]], [], []]
array.remove(array[0])
n -= 1
if array[n - 1] > 0:
	sets[1].append(array[n - 1])
	array.remove(array[n - 1])
else:
	sets[1].append(array[0])
	sets[1].append(array[1])
	array.remove(array[1])
	array.remove(array[0])
sets[2] = array
for i in range(3):
	print(len(sets[i]), end=' ')
	for num in sets[i]:
		print(num, end=' ')
	print()


n = int(input())
a = list(map(int, input().split(' ')))
neg = []
pos = []
z = []
for x in a:
	if x < 0:
		neg.append(str(x))
	elif x > 0:
		pos.append(str(x))
	else:
		z.append(str(x))
if len(pos) == 0:
	pos += neg[:2]
	neg = neg[2:]
if len(neg) % 2 == 0:
	z += neg[:1]
	neg = neg[1:]
print(len(neg), ' '.join(neg))
print(len(pos), ' '.join(pos))
print(len(z), ' '.join(z))


def Show(X):
	print(len(X), *X)
N = int(input())
X = list(map(int, input().split()))
(First, Second, Third) = (list(filter(lambda x: x < 0, X)), list(filter(lambda x: x > 0, X)), [0])
if len(Second) == 0:
	(Second.append(First.pop()), Second.append(First.pop()))
if len(First) % 2 == 0:
	Third.append(First.pop())
Show(First)
Show(Second)
Show(Third)


n = int(input())
m = list(map(int, input().split()))
a = []
b = []
for e in m:
	if e < 0:
		a += [e]
		m.remove(e)
		break
bb = 1
for e in m[:]:
	if e != 0:
		bb *= e
		b += [e]
		m.remove(e)
		if bb > 0:
			break
if bb < 0:
	t = min(b)
	m += [t]
	b.remove(t)
print(len(a), ' '.join(map(str, a)))
print(len(b), ' '.join(map(str, b)))
print(len(m), ' '.join(map(str, m)))


n = int(input())
l = sorted(list(map(int, input().split())))
print(1, l.pop(0))
if l[-1] > 0:
	print(1, l.pop())
	print(n - 2, *l)
else:
	print(2, l.pop(0), l.pop(0))
	print(n - 3, *l)


import math, sys
n = int(input())
a = [int(i) for i in input().split()]
a1 = []
a2 = []
a3 = []
c = 0
f = 0
for i in a:
	if i < 0:
		c += 1
if c >= 3:
	f = 2
for i in a:
	if i < 0 and len(a1) == 0:
		a1.append(i)
	elif i > 0 and len(a2) == 0:
		a2.append(i)
	elif i < 0 and f > 0:
		a2.append(i)
		f -= 1
	else:
		a3.append(i)
print(1, *a1)
print(len(a2), *a2)
print(len(a3), *a3)


import functools as ft

def print_result():
	print('{} {}'.format(len(negative), ' '.join((str(element) for element in negative))))
	print('{} {}'.format(len(positive), ' '.join((str(element) for element in positive))))
	print('{} {}'.format(len(zero), ' '.join((str(element) for element in zero))))
number_of_values = int(input())
values = list(map(int, input().split()))
positive = list(filter(lambda x: x > 0, values))
negative = list(filter(lambda x: x < 0, values))
zero = list(filter(lambda x: x == 0, values))
if len(positive) == 0:
	positive.append(negative.pop())
	positive.append(negative.pop())
product_of_negative = ft.reduce(lambda x, y: x * y, negative)
if product_of_negative < 0:
	print_result()
else:
	zero.append(negative.pop())
	print_result()


zero_list = []
input_list = []
negative_list = []
positive_list = []
n = input()
input_string = input().split()
input_list = [int(number) for number in input_string]
for number in input_list:
	if number == 0:
		zero_list.append(number)
	if number < 0:
		negative_list.append(number)
	if number > 0:
		positive_list.append(number)
if len(negative_list) % 2 == 0:
	zero_list.append(negative_list.pop())
if len(positive_list) == 0:
	positive_list.append(negative_list.pop())
	positive_list.append(negative_list.pop())

def print_list(sample_list):
	print(len(sample_list), end=' ')
	for x in sample_list:
		print(x, end=' ')
	print()
print_list(negative_list)
print_list(positive_list)
print_list(zero_list)


n = input()
inp = list(map(int, input().split()))
neg = list()
pos = list()
zero = list()
for num in inp:
	if num < 0:
		neg.append(num)
	elif num > 0:
		pos.append(num)
	else:
		zero.append(num)
print(1, neg[0])
if len(pos) == 0:
	print(2, neg[1], neg[2])
	del neg[0]
	del neg[1]
else:
	print(len(pos), end=' ')
	for x in pos:
		print(x, end=' ')
	print()
print(len(neg) + len(zero) - 1, end=' ')
for x in zero + neg[1:]:
	print(x, end=' ')


def main():
	n = int(input())
	arr = sorted(list(map(int, input().split())))
	a = []
	b = []
	c = []
	v = sorted([i for i in arr if i < 0])
	a.append(v[-1])
	del v[-1]
	ind = 0
	while ind <= len(v) - 1:
		if ind <= len(v) - 2:
			b.append(v[ind])
			b.append(v[ind + 1])
			ind += 2
		else:
			c.append(v[ind])
			ind += 1
	count = 0
	for i in arr:
		if i == 0:
			c.append(i)
		elif i > 0:
			b.append(i)
	print(len(a), ' '.join(map(str, a)))
	print(len(b), ' '.join(map(str, b)))
	print(len(c), ' '.join(map(str, c)))
main()


num = int(input())
l = list(map(int, input().rstrip().split()))
a = [[], [], []]
for i in l:
	if i < 0:
		a[0].append(i)
	elif i == 0:
		a[2].append(i)
	else:
		a[1].append(i)
if len(a[1]) == 0:
	a[1].append(a[0][0])
	a[1].append(a[0][1])
	del a[0][0:2]
if len(a[0]) % 2 == 0:
	a[2].append(a[0][0])
	del a[0][0]
for i in range(0, 3):
	print(len(a[i]), end=' ')
	for j in a[i]:
		print(j, end=' ')
	print('')


n = int(input())
a = sorted(list(map(int, input().split())))
pos = sum((i > 0 for i in a))
if pos == 0:
	set1 = [a[2]]
	set2 = a[:2]
	set3 = a[3:]
else:
	set1 = [a[0]]
	set2 = [i for i in a if i > 0]
	set3 = [i for i in a if i != a[0] and i <= 0]
for x in (set1, set2, set3):
	print(len(x), *x, sep=' ')


def main():
	n = int(input())
	test = input()
	b = test.split()
	a1 = []
	a2 = []
	a3 = []
	i = 0
	n1 = 0
	n2 = 0
	n3 = 0
	while i < n:
		if int(b[i]) < 0:
			a1.append(b[i])
			n1 = n1 + 1
		if int(b[i]) > 0:
			a2.append(b[i])
			n2 = n2 + 1
		if int(b[i]) == 0:
			a3.append(b[i])
			n3 = n3 + 1
		i = i + 1
	if n2 == 0:
		a2.append(a1[0])
		a1.pop(0)
		a2.append(a1[0])
		a1.pop(0)
		n2 = n2 + 2
		n1 = n1 - 2
	if n1 % 2 == 0:
		a3.append(a1[0])
		a1.pop(0)
		n3 = n3 + 1
		n1 = n1 - 1
	print(n1, ' '.join(map(str, a1)))
	print(n2, ' '.join(map(str, a2)))
	print(n3, ' '.join(map(str, a3)))
main()


N = int(input())
array = list(map(int, input().split()))
(set1, set2, set3) = ([], [], [])
counter = 0
for i in range(N):
	if array[i] < 0:
		set1.append(array[i])
	elif array[i] > 0:
		set2.append(array[i])
	elif array[i] == 0:
		set3.append(array[i])
if len(set2) == 0:
	set2.append(set1.pop())
	set2.append(set1.pop())
if len(set1) % 2 == 0:
	set3.append(set1.pop())
print(len(set1), ' '.join(map(str, set1)))
print(len(set2), ' '.join(map(str, set2)))
print(len(set3), ' '.join(map(str, set3)))


n = int(input())
L = list(map(int, input().split()))
L1 = []
L2 = []
a = 0
b = 0
for x in L:
	if x > 0:
		a = a + 1
	elif x < 0:
		b = b + 1
L.sort()
if a > 0:
	cnt = 0
	for i in L:
		if cnt == len(L) - 1:
			print(1, i)
			break
		elif i < 0 and cnt == 0:
			print(1, i)
		else:
			L1.append(i)
		cnt = cnt + 1
	print(len(L1), end=' ')
	cnt = 0
	for i in L1:
		if cnt != len(L1) - 1:
			s = ' '
		else:
			s = '\n'
		print(i, end=s)
else:
	cnt = 0
	for i in L:
		if i < 0 and cnt == 0:
			print(1, i)
		elif i < 0 and cnt <= 2:
			L2.append(i)
			if cnt == 2:
				print(len(L2), end=' ')
				f = 0
				for j in L2:
					if f == len(L2) - 1:
						s = '\n'
					else:
						s = ' '
					print(j, end=s)
					f = f + 1
		else:
			L1.append(i)
		cnt = cnt + 1
	(print(len(L1), end=' '),)
	cnt = 0
	for i in L1:
		if cnt != len(L1) - 1:
			s = ' '
		else:
			s = '\n'
		print(i, end=s)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = []
	minus = []
	zer = []
	for x in a:
		if x > 0:
			ans.append(x)
		elif x < 0:
			minus.append(x)
		else:
			zer.append(x)
	if len(ans) == 0:
		ans.extend(minus[:2])
		minus = minus[2:]
	if len(minus) % 2 == 0:
		zer.append(minus[0])
		minus = minus[1:]
	print(len(minus), end=' ')
	for x in minus:
		print(x, end=' ')
	print()
	print(len(ans), end=' ')
	for x in ans:
		print(x, end=' ')
	print()
	print(len(zer), end=' ')
	for x in zer:
		print(x, end=' ')
	print()
main()


n = int(input())
m = list(map(int, input().split()))
q = list(filter(lambda x: x > 0, m))
w = list(filter(lambda x: x < 0, m))
I = lambda x: ' '.join(map(str, x))
if len(q):
	print(1, w[0], '\n1', q[0], '\n' + str(n - 2), I(q[1:] + [0] + w[1:]))
else:
	print(1, w[0], '\n2', w[1], w[2], '\n' + str(n - 3), I(w[3:] + [0]))


no = int(input())
inp = list(map(int, input().split()))
chk = [True for i in range(no)]
a = []
b = []
c = []

def prod(a):
	if len(a) != 0:
		res = a[0]
	else:
		return 0
	for i in range(1, len(a)):
		res *= a[i]
	return res
for i in range(no):
	if inp[i] == 0:
		c.append(inp[i])
		chk[i] = False
for i in range(no):
	if chk[i] != False:
		if inp[i] > 0:
			b.append(inp[i])
			chk[i] = False
if len(b) == 0:
	for i in range(no):
		if chk[i] != False:
			if prod(b) <= 0:
				b.append(inp[i])
				chk[i] = False
			elif prod(b) > 0:
				break
else:
	i = 0
for j in range(i, no):
	if chk[j] != False:
		a.append(inp[j])
		chk[j] = False
		break
for i in range(j, no):
	if chk[i] != False:
		c.append(inp[i])
		chk[i] = False
print(len(a), end=' ')
for i in range(len(a)):
	print(a[i], end=' ')
print()
print(len(b), end=' ')
for i in range(len(b)):
	print(b[i], end=' ')
print()
print(len(c), end=' ')
for i in range(len(c)):
	print(c[i], end=' ')


n = int(input())
a = []
b = []
c = []
temp = list(map(int, input().split()))
for num in temp:
	if num > 0:
		a.append(num)
	elif num == 0:
		c.append(num)
	else:
		b.append(num)
if len(b) % 2 == 0:
	c.append(b.pop())
if len(a) == 0:
	a.append(b.pop())
	a.append(b.pop())
print(len(b), end=' ')
for i in range(len(b)):
	print(b[i], end=' ')
print()
print(len(a), end=' ')
for i in range(len(a)):
	print(a[i], end=' ')
print()
print(len(c), end=' ')
for i in range(len(c)):
	print(c[i], end=' ')
print()


n = int(input())
a = list(map(int, input().split()))
s1 = [i for i in a if i < 0]
s2 = [i for i in a if i > 0]
s3 = [i for i in a if i == 0]

def pr(x):
	print(len(x), ' '.join(map(str, x)))
if len(s2) == 0:
	s2.append(s1.pop())
	s2.append(s1.pop())
if len(s1) % 2 == 0:
	s3.append(s1.pop())
pr(s1)
pr(s2)
pr(s3)


def main():
	n = int(input())
	l = [int(i) for i in input().split()]
	l.sort()
	mi = l[0]
	ma = l[-1]
	io = l.index(0)
	nl = io + 1
	pl = len(l) - io - 1
	print(str(1) + ' ' + str(mi))
	if pl > 0:
		print(*[n - io - 1] + l[io + 1:])
		print(*[io] + l[1:io + 1])
	else:
		print(*[2] + l[1:3])
		print(*[n - 3] + l[3:])
	return 0
main()


import sys
import math
n = int(sys.stdin.readline())
an = [int(x) for x in sys.stdin.readline().split()]
an.sort()
nullind = 0
for i in range(n):
	if an[i] == 0:
		nullind = i
		break
p1 = 1
an1 = []
p2 = 1
an2 = []
p3 = 1
an3 = []
if i == n - 1:
	an1.append(an[n - 2])
	an2.append(an[n - 3])
	an2.append(an[n - 4])
	an3.append(0)
	for k in an[0:i - 3]:
		an3.append(k)
else:
	an1.append(an[i - 1])
	an2.append(an[i + 1])
	an3.append(0)
	for k in an[i + 2:]:
		an3.append(k)
	for k in an[:i - 1]:
		an3.append(k)
print(str(len(an1)) + ' ' + ' '.join([str(x) for x in an1]))
print(str(len(an2)) + ' ' + ' '.join([str(x) for x in an2]))
print(str(len(an3)) + ' ' + ' '.join([str(x) for x in an3]))


n = int(input())
l = [int(x) for x in input().split()]
l1 = []
l2 = []
l3 = []
for i in range(n):
	if l[i] < 0:
		l1.append(l[i])
	elif l[i] > 0:
		l2.append(l[i])
	else:
		l3.append(l[i])
if len(l1) % 2 == 0:
	l3.append(l1[len(l1) - 1])
	l1 = l1[:len(l1) - 1]
if len(l2) == 0:
	l2.append(l1[len(l1) - 1])
	l2.append(l1[len(l1) - 2])
	l1 = l1[:len(l1) - 2]
print(len(l1), end=' ')
for i in range(len(l1)):
	print(l1[i], end=' ')
print('')
print(len(l2), end=' ')
for i in range(len(l2)):
	print(l2[i], end=' ')
print('')
print(len(l3), end=' ')
for i in range(len(l3)):
	print(l3[i], end=' ')
print('')


n = int(input())
all = sorted([int(string) for string in input().split()])
first = []
second = []
third = []
for a in all:
	if a < 0 and len(first) == 0:
		first.append(a)
	elif a < 0 and len(second) < 2 and (all.index(0) > 2):
		second.append(a)
	elif a > 0 and len(second) == 0:
		second.append(a)
	else:
		third.append(a)
print(' '.join([str(f) for f in [len(first)] + first]))
print(' '.join([str(f) for f in [len(second)] + second]))
print(' '.join([str(f) for f in [len(third)] + third]))


n = int(input())
a = [int(s) for s in input().split()]
otr = []
pol = []
nul = []
ind = []
ko = kp = kop = kn = ki = 0
for i in range(n):
	if a[i] == 0:
		kn += 1
		nul.append(a[i])
	elif a[i] > 0:
		kp += 1
		pol.append(a[i])
	elif ko == 0:
		ko += 1
		otr.append(a[i])
	else:
		ki += 1
		ind.append(a[i])
if kp > 0:
	kn += ki
	for i in range(ki):
		nul.append(ind[i])
else:
	kp += 2
	pol.append(ind[0])
	pol.append(ind[1])
	if ki > 2:
		kn += ki - 2
		for i in range(2, ki):
			nul.append(ind[i])
print(ko, end=' ')
for i in range(ko):
	print(otr[i], end=' ')
print()
print(kp, end=' ')
for i in range(kp):
	print(pol[i], end=' ')
print()
print(kn, end=' ')
for i in range(kn):
	print(nul[i], end=' ')
print()


n = int(input())
x = [int(i) for i in input().split()]
(a, b) = ([], [])
for i in x:
	if i < 0:
		a += [i]
		break
for i in x:
	if i > 0:
		b += [i]
		break
if b == []:
	x.pop(x.index(a[0]))
	for i in x:
		if i < 0:
			b += [i]
			break
	x.pop(x.index(b[0]))
	for i in x:
		if i < 0:
			b += [i]
			break
	x.pop(x.index(b[1]))
	print(1, a[0])
	print(2, *b)
	print(len(x), *x)
else:
	x.pop(x.index(a[0]))
	x.pop(x.index(b[0]))
	print(1, a[0])
	print(1, b[0])
	print(len(x), *x)


n = int(input())
a = list(map(int, input().split()))
d1 = [x for x in a if x < 0]
d2 = [x for x in a if x > 0]
d3 = [x for x in a if x == 0]
if len(d2) == 0:
	d2.append(d1.pop())
	d2.append(d1.pop())
if len(d1) % 2 == 0:
	d3.append(d1.pop())
print(len(d1), end=' ')
for x in d1:
	print(x, end=' ')
print()
print(len(d2), end=' ')
for x in d2:
	print(x, end=' ')
print()
print(len(d3), end=' ')
for x in d3:
	print(x, end=' ')
print()


def getGroups(n, arr):
	indexZero = -1
	indexPos = -1
	for i in range(n):
		if indexZero == -1 and arr[i] == 0:
			indexZero = i
		if arr[i] > 0:
			indexPos = i
			break
	if indexPos == -1:
		if indexZero % 2 == 0:
			return (arr[:indexZero - 3], arr[indexZero - 2:indexZero], arr[indexZero:] + [arr[indexZero - 3]])
		else:
			return (arr[:indexZero - 2], arr[indexZero - 2:indexZero], arr[indexZero:])
	elif indexZero % 2 == 0:
		return (arr[:indexZero - 1], arr[indexPos:], arr[indexZero:indexPos] + [arr[indexZero - 1]])
	else:
		return (arr[:indexZero], arr[indexPos:], arr[indexZero:indexPos])
n = int(input().rstrip())
temp = list(map(int, input().rstrip().split()))
temp.sort()
(groupN, groupP, groupZ) = getGroups(n, temp)
stringN = str(len(groupN))
stringP = str(len(groupP))
stringZ = str(len(groupZ))
for i in groupN:
	stringN += ' ' + str(i)
for i in groupP:
	stringP += ' ' + str(i)
for i in groupZ:
	stringZ += ' ' + str(i)
print(stringN)
print(stringP)
print(stringZ)


n = int(input())
ns = [int(x) for x in input().split()]
s = [[], [], []]
for num in ns:
	if num == 0:
		s[2].append(num)
	elif num > 0:
		s[1].append(num)
	else:
		s[0].append(num)
if len(s[1]) == 0:
	for i in range(2):
		s[1].append(s[0][-1])
		del s[0][-1]
if len(s[0]) % 2 == 0:
	s[2].append(s[0][-1])
	del s[0][-1]
for i in s:
	print(str(len(i)) + ' ' + ' '.join((str(x) for x in i)))


n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	if a[i] < 0:
		print(1, a[i])
		a[i] = 2000
		break
flag = False
for i in range(n):
	if a[i] > 0 and a[i] != 2000:
		print(1, a[i])
		a[i] = 2000
		flag = True
		break
sequence = []
if not flag:
	count = 3
	for i in range(n):
		if a[i] < 0:
			sequence.append(a[i])
			a[i] = 2000
		if len(sequence) == 2:
			break
	print(2, end=' ')
	for i in range(2):
		print(sequence[i], end=' ')
	print()
else:
	count = 2
print(n - count, end=' ')
for i in range(n):
	if a[i] != 2000:
		print(a[i], end=' ')


import math

def mul(a):
	mul = 1
	for i in a:
		mul *= i
	return mul
n = int(input())
l = list(map(int, input().split()))
count_m = 0
a = []
b = []
c = []
for i in l:
	if i < 0:
		count_m += 1
for i in l:
	if i < 0:
		if len(a) == 0:
			a.append(i)
			count_m -= 1
		elif len(b) == 0:
			if count_m > 1:
				b.append(i)
			else:
				c.append(i)
		elif mul(b) < 0:
			b.append(i)
		else:
			c.append(i)
	elif i > 0:
		b.append(i)
	else:
		c.append(i)
o = []
o.append(a)
o.append(b)
o.append(c)
for i in o:
	print(len(i), end=' ')
	for j in i:
		print(j, end=' ')
	print()


n = int(input())
arr = [int(i) for i in input().split()]
neg = []
pos = []
zero = [0]
for i in range(n):
	if arr[i] < 0:
		neg.append(arr[i])
	elif arr[i] > 0:
		pos.append(arr[i])
if len(neg) >= 1:
	print(1, neg[0])
	neg.pop(0)
if len(pos) == 0:
	if len(neg) >= 2:
		print(2, neg[0], neg[1])
		neg.pop(0)
		neg.pop(0)
else:
	print(1, pos[0])
	pos.pop(0)
zeros = neg + pos + [0]
print(len(zeros), end=' ')
print(*zeros)


n = int(input())
L = list(map(int, input().split()))
d = {-1: [], 0: [0], 1: []}
for i in range(len(L)):
	if L[i] < 0:
		d[-1].append(L[i])
	elif L[i] > 0:
		d[1].append(L[i])
if len(d[-1]) % 2 != 0:
	if len(d[1]) != 0:
		print(len(d[-1]), *d[-1])
		print(len(d[1]), *d[1])
		print('1 0')
	else:
		print(len(d[-1]) - 2, *d[-1][2:])
		print(2, *d[-1][:2])
		print('1 0')
elif len(d[1]) != 0:
	print(len(d[-1]) - 1, *d[-1][1:])
	d[0].append(d[-1][0])
	print(len(d[1]), *d[1])
	print(len(d[0]), *d[0])
else:
	print(len(d[-1]) - 3, *d[-1][3:])
	d[0].append(d[-1][2])
	print(2, *d[-1][:2])
	print(len(d[0]), *d[0])


n = int(input())
a = list(input().split())
b = []
for i in range(n):
	b.append(int(a[i]))
p = 0
m = 0
c = []
d = []
e = []
for i in range(n):
	if b[i] > 0:
		p = p + 1
	if b[i] < 0:
		m = m + 1
if p > 0 and m > 0:
	if m % 2 != 0:
		k = True
		j = 0
		while k:
			if b[j] < 0:
				c.append(b[j])
				del b[j]
				k = False
			j = j + 1
		for i in range(len(b)):
			if b[i] != 0:
				d.append(b[i])
			else:
				e.append(b[i])
	else:
		k = True
		j = 0
		while k:
			if b[j] < 0:
				c.append(b[j])
				del b[j]
				k = False
			j = j + 1
		i = 0
		k = True
		while k:
			if b[i] < 0:
				e.append(b[i])
				del b[i]
				k = False
			i = i + 1
		for l in range(len(b)):
			if b[l] != 0:
				d.append(b[l])
			else:
				e.append(b[l])
else:
	k = True
	j = 0
	while k:
		if b[j] < 0:
			c.append(b[j])
			del b[j]
			k = False
		j = j + 1
	if m % 2 != 0:
		for i in range(len(b)):
			if b[i] < 0:
				d.append(b[i])
			else:
				e.append(b[i])
	else:
		q = 0
		k = True
		while k:
			if b[q] < 0:
				e.append(b[q])
				del b[q]
				k = False
			q = q + 1
		for i in range(len(b)):
			if b[i] < 0:
				d.append(b[i])
			else:
				e.append(b[i])
print(len(c), end=' ')
print(c[0])
print(len(d), end=' ')
for i in range(len(d)):
	print(d[i], end=' ')
print()
print(len(e), end=' ')
for i in range(len(e)):
	print(e[i], end=' ')


n = int(input())
a = sorted(list(map(int, input().split())))
a1 = []
a2 = []
a3 = []
i = 0
count = 0
while i < len(a):
	if a[i] < 0:
		a1.append(a[i])
		count += 1
		i += 1
	elif a[i] == 0:
		a3.append(a[i])
		i += 1
	else:
		a2.append(a[i])
		i += 1
if len(a2) == 0:
	a2.append(a1.pop())
	a2.append(a1.pop())
if count % 2 == 0:
	a3.append(a1.pop())
print(len(a1), *a1)
print(len(a2), *a2)
print(len(a3), *a3)


n = int(input())
(p1, p2, p3) = ([], [], [])
for i in list(map(int, input().split())):
	if i < 0:
		p1.append(i)
	if i > 0:
		p2.append(i)
	if i == 0:
		p3.append(i)
if len(p1) % 2 == 0:
	p3.append(p1.pop())
if len(p2) == 0:
	p2.append(p1.pop())
	p2.append(p1.pop())
print(*[len(p1)] + p1)
print(*[len(p2)] + p2)
print(*[len(p3)] + p3)


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 list(map(int, sys.stdin.readline().split()))

def LLI():
	return [tuple(map(int, l.split())) for l in sys.stdin]

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()
	a = sorted(LI())
	b = [a[0]]
	c = []
	d = []
	if a[-1] > 0:
		c.append(a[-1])
		d = a[1:-1]
	else:
		c = a[1:3]
		d = a[3:]
	r = [b, c, d]
	return '\n'.join(map(lambda x: '{} {}'.format(len(x), ' '.join(map(str, x))), r))
print(main())


n = int(input())
a = []
b = []
c = []
inp = 0
od = 0
ev = 0
l = [int(i) for i in input().split()]
l.sort()
for i in l:
	if i < 0:
		od += 1
		a.append(i)
	elif i > 0:
		ev += 1
		b.append(i)
	elif i == 0:
		c.append(i)
if len(b) == 0:
	for i in range(2):
		b.append(a.pop(0))
		ev += 1
		ev += 1
if od % 2 == 0:
	c.append(a.pop(0))
print(len(a), *a)
print(len(b), *b)
print(len(c), *c)


n = int(input())
l = list(map(int, input().split()))
neg = list(filter(lambda x: x < 0, l))
pos = list(filter(lambda x: x > 0, l))
if len(pos) == 0:
	po = neg[:2]
	l.remove(po[0])
	l.remove(po[1])
	l.remove(neg[2])
	print(1, neg[2])
	print(2, *po)
	print(len(l), *l)
else:
	l.remove(pos[0])
	l.remove(neg[0])
	print(1, neg[0])
	print(1, pos[0])
	print(len(l), *l)


n = int(input())
arr = list(map(int, input().split()[:n]))
arr1 = []
arr2 = []
arr3 = []
for i in arr:
	if i == 0:
		arr3.append(i)
	elif i < 0:
		arr1.append(i)
	else:
		arr2.append(i)
if len(arr1) % 2 == 0:
	arr3.append(arr1[-1])
	arr1.pop()
if len(arr2) == 0:
	arr2.append(arr1[-1])
	arr2.append(arr1[-2])
	arr1.pop()
	arr1.pop()
print('{0}'.format(len(arr1)), end=' ')
for i in arr1:
	print(i, end=' ')
print()
print('{0}'.format(len(arr2)), end=' ')
for i in arr2:
	print(i, end=' ')
print()
print('{0}'.format(len(arr3)), end=' ')
for i in arr3:
	print(i, end=' ')


import sys

class MyReader:

	def __init__(self):
		filename = 'file.in'
		if self.isLocal():
			self.file = open(filename)
		self.str = ['']
		self.ind = 1

	def isLocal(self):
		return len(sys.argv) > 1 and sys.argv[1] == 'SCHULLZ'

	def nextString(self):
		if self.isLocal():
			return self.file.read()
		else:
			return input()

	def nextInt(self):
		return int(self.nextToken())

	def nextToken(self):
		if self.ind >= len(self.str):
			self.ind = 0
			self.str = self.nextString().split()
		self.ind += 1
		return self.str[self.ind - 1]
rdr = MyReader()
n = rdr.nextInt()
a = []
pos = []
neg = []
nul = []
for i in range(0, n):
	a.append(rdr.nextInt())
i0 = 0
a.sort()
if len(a) >= 3 and a[0] < 0 and (a[1] < 0) and (a[n - 1] == 0):
	i0 = 2
	pos.append(a[0])
	pos.append(a[1])
for i in range(i0, n):
	if a[i] > 0:
		pos.append(a[i])
	elif a[i] < 0 and len(neg) == 0:
		neg.append(a[i])
	else:
		nul.append(a[i])
sys.stdout.write(str(len(neg)))
sys.stdout.write(' ')
for i in range(0, len(neg)):
	sys.stdout.write(str(neg[i]))
	sys.stdout.write(' ')
sys.stdout.write('\n')
sys.stdout.write(str(len(pos)))
sys.stdout.write(' ')
for i in range(0, len(pos)):
	sys.stdout.write(str(pos[i]))
	sys.stdout.write(' ')
sys.stdout.write('\n')
sys.stdout.write(str(len(nul)))
sys.stdout.write(' ')
for i in range(0, len(nul)):
	sys.stdout.write(str(nul[i]))
	sys.stdout.write(' ')
sys.stdout.write('\n')
sys.stdout.flush()


n = int(input())
a = list(map(int, input().split()))[:]
c = k = 0
n1 = []
n2 = []
n3 = []
a.sort()
print(1, a[0])
if a[n - 1] > 0:
	print(1, a[n - 1])
	print(n - 2, *a[1:n - 1])
else:
	print(2, a[1], a[2])
	print(n - 3, *a[3:])


n = int(input())
arr = list(map(int, input().split()))
f = None
s = ''
t = ''
pairs = []
num_t = 0
for elem in arr:
	if elem < 0:
		if f == None:
			f = elem
		else:
			pairs.append(elem)
	elif elem > 0:
		s += str(elem) + ' '
	else:
		t += str(elem) + ' '
		num_t += 1
	if len(pairs) >= 2:
		s += str(pairs.pop()) + ' '
		s += str(pairs.pop()) + ' '
if pairs:
	t += str(pairs[0]) + ' '
	num_t += 1
print('1 ' + str(f))
print(str(n - 1 - num_t) + ' ' + s[:-1])
print(str(num_t) + ' ' + t[:-1])


n = int(input())
list_of_numbers = list(map(int, input().split()))
print(1, end=' ')
print(min(list_of_numbers))
list_of_numbers.remove(min(list_of_numbers))
count_negatives = 0
for i in range(len(list_of_numbers)):
	if list_of_numbers[i] < 0:
		count_negatives += 1
if count_negatives % 2 == 0:
	list_of_numbers.remove(0)
	print(len(list_of_numbers), end=' ')
	print(*list_of_numbers)
	print(1, end=' ')
	print(0)
else:
	second_min = min(list_of_numbers)
	list_of_numbers.remove(second_min)
	list_of_numbers.remove(0)
	print(len(list_of_numbers), end=' ')
	print(*list_of_numbers)
	print(2, end=' ')
	print(second_min, end=' ')
	print(0)


n = int(input())
lst = [int(i) for i in input().strip().split()]
z_set = []
n_set = []
p_set = []
p_c = 0
n_c = 0
n_f = 0
for i in lst:
	if i == 0:
		z_set.append(i)
	elif i > 0:
		p_set.append(i)
	else:
		n_set.append(i)
if len(n_set) % 2 == 0:
	z_set.append(n_set[0])
	n_set = n_set[1:]
if len(p_set) == 0:
	p_set.append(n_set[0])
	p_set.append(n_set[1])
	n_set = n_set[2:]
print(len(n_set), end=' ')
for i in range(len(n_set)):
	if i != len(n_set) - 1:
		print(n_set[i], end=' ')
	else:
		print(n_set[i])
print(len(p_set), end=' ')
for i in range(len(p_set)):
	if i != len(p_set) - 1:
		print(p_set[i], end=' ')
	else:
		print(p_set[i])
print(len(z_set), end=' ')
for i in range(len(z_set)):
	if i != len(z_set) - 1:
		print(z_set[i], end=' ')
	else:
		print(z_set[i])


def ans(arr):
	lz = []
	gz = []
	ez = []
	for i in range(len(arr)):
		if arr[i] < 0:
			lz.append(arr[i])
		elif arr[i] > 0:
			gz.append(arr[i])
		elif arr[i] is 0:
			ez.append(arr[i])
	if len(lz) % 2 is 0:
		temp = lz.pop()
		ez.append(temp)
	if len(gz) is 0:
		x = lz.pop()
		y = lz.pop()
		gz.append(x)
		gz.append(y)
	a1 = []
	a2 = []
	a3 = []
	a1.append(len(lz))
	for i in range(len(lz)):
		a1.append(lz[i])
	a2.append(len(gz))
	for i in range(len(gz)):
		a2.append(gz[i])
	a3.append(len(ez))
	for i in range(len(ez)):
		a3.append(ez[i])
	for i in range(len(a1) - 1):
		print(a1[i], end=' ')
	print(a1[len(a1) - 1])
	for i in range(len(a2) - 1):
		print(a2[i], end=' ')
	print(a2[len(a2) - 1])
	for i in range(len(a3) - 1):
		print(a3[i], end=' ')
	print(a3[len(a3) - 1])
n = int(input())
arr = list(map(int, input().strip().split(' ')))
ans(arr)


n = int(input())
a = list(map(int, input().split()))
(l1, l2, l3) = ([], [], [])
for i in range(n):
	if a[i] < 0:
		l1.append(a[i])
	elif a[i] > 0:
		l2.append(a[i])
	elif a[i] == 0:
		l3.append(a[i])
if len(l2) == 0:
	for i in range(2):
		l2.append(l1.pop(-1))
if len(l1) % 2 == 0:
	l3.append(l1.pop(-1))
print(len(l1), *l1)
print(len(l2), *l2)
print(len(l3), *l3)


from sys import stdin, stdout
if not __debug__:
	stdin = open('input.txt', 'r')
tcs = int(stdin.readline()) if not __debug__ else 1
t = 1
while t <= tcs:
	n = int(stdin.readline().strip())
	li = list(map(int, stdin.readline().split()))
	arr = [[], [], []]
	for i in li:
		if i < 0:
			arr[0].append(i)
		elif i > 0:
			arr[1].append(i)
		else:
			arr[2].append(i)
	if len(arr[0]) % 2 == 0:
		arr[2].append(arr[0].pop(-1))
	if len(arr[1]) == 0:
		arr[1].append(arr[0].pop(-1))
		arr[1].append(arr[0].pop(-1))
	print(len(arr[0]), ''.join((str(y) + ' ' for y in arr[0])))
	print(len(arr[1]), ''.join((str(y) + ' ' for y in arr[1])))
	print(len(arr[2]), ''.join((str(y) + ' ' for y in arr[2])))
	t += 1


input()
z = sorted(map(int, input().split()))
n = [z.pop(0)]
p = z[-1] > 0 and [z.pop()] or [z.pop(0), z.pop(0)]
for i in (n, p, z):
	print(len(i), *i)


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

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 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:
			factors.add(n // i)
			n = n // i
			factors.add(i)
	if n > 1:
		factors.add(n)
	return factors

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 solve(n):
	if n == 1:
		return 1
	p = 2
	while p * p <= n:
		if n % p == 0:
			return n // p
		p = p + 1
	return False

def expo(x, n):
	result = 1
	while n > 1:
		if n & 1:
			n = n - 1
			result = result * x
		else:
			n = n // 2
			x = x * x
	return result * x

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()
A = []
B = []
C = []
for i in Arr:
	if i < 0:
		A.append(i)
	elif i > 0:
		B.append(i)
	else:
		C.append(i)
if not len(A) & 1:
	C.append(A[-1])
	del A[-1]
if len(B) == 0:
	B.append(A[-1])
	B.append(A[-2])
	del A[-1]
	del A[-1]
print(len(A), *A, sep=' ')
print(len(B), *B, sep=' ')
print(len(C), *C, sep=' ')


n = int(input())
a = list(map(int, input().split()))
arrayd = []
arraya = []
arrayk = []
for x in a:
	if x > 0:
		arrayd.append(x)
	elif x == 0:
		arrayk.append(x)
	else:
		arraya.append(x)
if len(arrayd) == 0:
	arrayd.append(arraya[-1])
	arrayd.append(arraya[-2])
	arraya = arraya[:len(arraya) - 2]
if len(arraya) % 2 == 0:
	arrayk.append(arraya[-1])
	arraya = arraya[:len(arraya) - 1]
print(len(arraya), end=' ')
for x in arraya:
	print(x, end=' ')
print()
print(len(arrayd), end=' ')
for x in arrayd:
	print(x, end=' ')
print()
print(len(arrayk), end=' ')
for x in arrayk:
	print(x, end=' ')


n = int(input())
a = [int(a) for a in input().split()]
neg = []
pos = []
zer = []
for i in a:
	if i < 0:
		neg.append(i)
	elif i > 0:
		pos.append(i)
	else:
		zer.append(i)
if len(pos) == 0:
	pos.append(neg[0])
	pos.append(neg[1])
	neg.pop(0)
	neg.pop(0)
if len(neg) % 2 == 0:
	zer.append(neg[0])
	neg.pop(0)
print(len(neg), end=' ')
for i in neg:
	print(i, end=' ')
print()
print(len(pos), end=' ')
for i in pos:
	print(i, end=' ')
print()
print(len(zer), end=' ')
for i in zer:
	print(i, end=' ')


leng = int(input())
lst = list(map(int, input().split()))
used = [False] * leng
lst1 = []
lst2 = []
lst3 = []
p1 = 1
p2 = 1
p3 = 1
for i in range(len(lst)):
	cur = lst[i]
	if cur < 0:
		if p2 < 0:
			lst2.append(cur)
			p2 *= cur
			used[i] = True
		elif p1 > 0:
			lst1.append(cur)
			p1 *= cur
			used[i] = True
	elif cur > 0:
		if p1 < 0 and len(lst2) != 0:
			lst1.append(cur)
			p1 *= cur
			used[i] = True
		elif p2 > 0:
			lst2.append(cur)
			p2 *= cur
			used[i] = True
	else:
		lst3.append(cur)
		used[i] = True
		p3 *= cur
for i in range(len(lst)):
	if not used[i]:
		cur = lst[i]
		if len(lst1) == 0:
			lst1.append(lst[i])
			p1 *= cur
		elif len(lst2) == 0:
			lst2.append(lst[i])
			p2 *= cur
		elif len(lst3) == 0:
			lst3.append(lst[i])
			p3 *= cur
		elif lst[i] < 0:
			if p2 < 0:
				lst2.append(lst[i])
				p2 *= cur
			else:
				lst3.append(lst[i])
		else:
			lst3.append(lst[i])
print(str(len(lst1)), end=' ')
for i in range(len(lst1)):
	print(str(lst1[i]), end=' ')
print()
print(str(len(lst2)), end=' ')
for i in range(len(lst2)):
	print(str(lst2[i]), end=' ')
print()
print(str(len(lst3)), end=' ')
for i in range(len(lst3)):
	print(str(lst3[i]), end=' ')
print()


n = int(input())
line = str(input()).split()
line = [int(it) for it in line]
line.sort()
line = [str(it) for it in line]
size = len(line)
if int(line[-1]) > 0:
	print('1 ' + line[0])
	print('1 ' + line[-1])
	print(str(size - 2) + ' ' + ' '.join(line[1:-1]))
else:
	print('1 ' + line[0])
	print('2 ' + ' '.join(line[1:3]))
	print(str(size - 3) + ' ' + ' '.join(line[3:]))


n = int(input())
l = [int(x) for x in input().split()]
neg = list(filter(lambda x: x < 0, l))
pos = list(filter(lambda x: x > 0, l))
zer = list(filter(lambda x: x == 0, l))
if len(pos) == 0:
	(pos, neg) = (neg[:2], neg[2:])
if len(neg) % 2 == 0:
	zer.append(neg.pop())
print(len(neg), ' '.join((str(i) for i in neg)))
print(len(pos), ' '.join((str(i) for i in pos)))
print(len(zer), ' '.join((str(i) for i in zer)))


import sys
n = int(input())
a = list(map(int, sys.stdin.readline().split()))
mi = min(a)
print(1, mi)
a.pop(a.index(mi))
ma = max(a)
if ma > 0:
	print(1, ma)
	a.pop(a.index(ma))
else:
	mi1 = min(a)
	a.pop(a.index(mi1))
	mi2 = min(a)
	a.pop(a.index(mi2))
	print(2, mi1, mi2)
print(len(a), ' '.join([str(i) for i in a]))


size = int(input())
arr = list(map(int, input().split(' ')))
zeros = ['0' for i in range(arr.count(0))]
negatives = [str(i) for i in arr if i < 0]
positives = [str(i) for i in arr if i > 0]
if positives == []:
	positives = negatives[:2]
	negatives = negatives[2:]
if len(negatives) % 2 == 0:
	zeros = zeros + [negatives[0]]
	negatives = negatives[1:]
print(len(negatives), ' '.join(negatives))
print(len(positives), ' '.join(positives))
print(len(zeros), ' '.join(zeros))


n = int(input())
a = list(map(int, input().split()))
b = []
k = 0
k1 = 0
for i in range(0, n):
	if a[i] == 0:
		b.append(a[i])
	elif a[i] > 0:
		if k == 0:
			k = a[i]
		else:
			b.append(a[i])
	elif a[i] < 0:
		if k1 == 0:
			k1 = a[i]
		else:
			b.append(a[i])
print(1, k1)
f = 0
if k == 0:
	c = []
	for i in range(0, n):
		if b[i] < 0:
			c.append(b[i])
			b[i] = '@'
			f = f + 1
		if len(c) == 2:
			break
	print(2)
	for i in range(0, 2):
		print(c[i])
else:
	print(1, k)
print(len(b) - f)
for i in range(0, len(b)):
	if b[i] != '@':
		print(b[i])


n = int(input())
l = list(map(int, input().split()))
(ne, po, ze) = ([], [], [])
for a in l:
	if a < 0:
		if len(ne) == 0:
			ne.append(a)
		elif len(po) == 0 or (len(po) == 1 and po[0] < 0):
			po.append(a)
		else:
			ze.append(a)
	elif 0 < a:
		if len(po) == 0:
			po.append(a)
		elif len(po) == 1 and po[0] < 0:
			ze.append(po[0])
			po[0] = a
		else:
			ze.append(a)
	else:
		ze.append(a)
print(len(ne), ' '.join(map(str, ne)))
print(len(po), ' '.join(map(str, po)))
print(len(ze), ' '.join(map(str, ze)))


def divarr(t):
	(neg, pos, zero) = (set(), set(), set([0]))
	for v in t:
		if v < 0:
			neg.add(v)
		elif v > 0:
			pos.add(v)
	if len(pos) == 0:
		pos.add(neg.pop())
		pos.add(neg.pop())
	while len(neg) != 1:
		zero.add(neg.pop())
	return (neg, pos, zero)
n = int(input())
vals = list(map(lambda x: int(x), input().split(' ')))
ret = divarr(vals)

def printset(s):
	r = '{}'.format(len(s))
	for e in s:
		r += ' {}'.format(e)
	print(r)
printset(ret[0])
printset(ret[1])
printset(ret[2])


n = int(input())
s2 = []
a = [int(z) for z in input().split()]
for i in range(n):
	if a[i] < 0:
		s1 = [a.pop(i)]
		break
for i in range(n - 1):
	if a[i] > 0:
		s2 = [a.pop(i)]
		break
if not s2:
	a.sort()
	s2 = a[:2]
	a = a[2:]
for t in (s1, s2, a):
	print(len(t), *t)


N = int(input())
arr = list(map(int, input().split()))
a = [arr[i] for i in range(len(arr)) if arr[i] < 0]
b = [arr[i] for i in range(len(arr)) if arr[i] > 0]
c = [0 for i in range(len(arr)) if arr[i] == 0]
if len(b) == 0:
	b.append(a[len(a) - 1])
	b.append(a[len(a) - 2])
	a.pop()
	a.pop()
if len(a) % 2 == 0:
	c.append(a[len(a) - 1])
	a.pop()
print(len(a), *a)
print(len(b), *b)
print(len(c), *c)


n = int(input())
a = list(map(int, input().split()))
first = []
second = []
third = []
first_negative = 0
second_negative = 0
countNegative = 0
appeared = False
for i in range(n):
	if a[i] < 0:
		if first_negative == 0:
			first.append(a[i])
			first_negative += 1
		countNegative += 1
	elif a[i] == 0:
		hasZero = True
		third.append(0)
	elif a[i] > 0:
		second.append(a[i])
if countNegative > 2:
	for i in range(n):
		if a[i] < 0 and (not appeared):
			appeared = True
		elif a[i] < 0 and second_negative < 2:
			second_negative += 1
			second.append(a[i])
		elif a[i] < 0:
			third.append(a[i])
else:
	for i in range(n):
		if a[i] < 0 and (not appeared):
			appeared = True
		elif a[i] < 0:
			third.append(a[i])
print(len(first), end=' ')
for i in range(len(first)):
	print(first[i], end=' ')
print()
print(len(second), end=' ')
for i in range(len(second)):
	print(second[i], end=' ')
print()
print(len(third), end=' ')
for i in range(len(third)):
	print(third[i], end=' ')
print()


t = int(input())
l = list(map(int, input().rstrip().split(' ')))
c_n = 0
c_p = 0
c_z = 0
for i in l:
	if i < 0:
		c_n += 1
	elif i > 0:
		c_p += 1
	else:
		c_z += 1
l.sort()
if c_n % 2:
	l1 = [l[0]]
	l2 = [l[i] for i in range(1, t) if l[i] != 0]
	l3 = [l[i] for i in range(1, t) if l[i] == 0]
else:
	l1 = [l[0]]
	l2 = [l[i] for i in range(1, t) if l[i] != 0]
	l3 = [l[i] for i in range(1, t) if l[i] == 0]
	l2.pop(0)
	l3.append(l[1])
print(1, l1[0])
print(len(l2), end=' ')
for j in l2:
	print(j, end=' ')
print('')
print(len(l3), end=' ')
for k in l3:
	print(k, end=' ')


n = int(input())
l = list(map(int, input().split()))
a = []
b = []
c = []
for i in l:
	if i < 0:
		a.append(i)
	elif i == 0:
		b.append(i)
	else:
		c.append(i)
print(1, a[0])
if len(c) == 0:
	print(2, a[1], a[2])
	print(n - 3, end=' ')
	for i in a[3:]:
		print(i, end=' ')
	print(0)
else:
	print(1, c[0])
	print(n - 2, end=' ')
	for i in a[1:]:
		print(i, end=' ')
	for j in c[1:]:
		print(j, end=' ')
	print(0)


n = int(input())
a = map(int, input().split())
s1 = []
s2 = []
s3 = []
for i in a:
	if i < 0:
		s1.append(i)
	elif i > 0:
		s2.append(i)
	else:
		s3.append(i)
if len(s2) == 0:
	s2.append(s1.pop())
	s2.append(s1.pop())
if len(s1) % 2 == 0:
	s3.append(s1.pop())
print(len(s1), ' '.join(map(str, s1)))
print(len(s2), ' '.join(map(str, s2)))
print(len(s3), ' '.join(map(str, s3)))


n = int(input())
arr = [int(i) for i in input().split()]
ans1 = []
ans2 = []
ans3 = []
c1 = 0
c2 = 0
for i in range(n):
	if arr[i] < 0:
		c1 += 1
		ans1.append(arr[i])
	if arr[i] > 0:
		c2 += 1
		ans2.append(arr[i])
	if arr[i] == 0:
		ans3.append(0)
if c1 % 2 == 0 and c2 != 0:
	ans3.append(ans1[-1])
	del ans1[-1]
if c2 == 0:
	ans2.append(ans1[-1])
	ans2.append(ans1[-2])
	del ans1[-1]
	del ans1[-1]
	c1 -= 2
	if c1 % 2 == 0:
		ans3.append(ans1[-1])
		del ans1[-1]
print(len(ans1), end=' ')
for i in ans1:
	print(i, end=' ')
print()
print(len(ans2), end=' ')
for i in ans2:
	print(i, end=' ')
print()
print(len(ans3), end=' ')
for i in ans3:
	print(i, end=' ')


n = int(input())
ll = list(map(int, input().split()))
l = [[], [], []]
for i in ll:
	if i < 0:
		l[0].append(str(i))
	elif i > 0:
		l[2].append(str(i))
	else:
		l[1].append(str(0))
if len(l[0]) % 2 == 0:
	if len(l[2]) == 0:
		l[2].append(l[0][-1])
		del l[0][-1]
		l[2].append(l[0][-1])
		del l[0][-1]
	l[1].append(l[0][0])
	del l[0][0]
elif len(l[2]) == 0:
	l[2].append(l[0][-1])
	del l[0][-1]
	l[2].append(l[0][-1])
	del l[0][-1]
print(len(l[0]), ' '.join(l[0]))
print(len(l[2]), ' '.join(l[2]))
print(len(l[1]), ' '.join(l[1]))


n = int(input())
a = list(map(int, input().split()))
(b, c, d) = ([], [], [])
for i in a:
	if i > 0:
		b.append(i)
	if i < 0:
		c.append(i)
	if i == 0:
		d.append(i)
l = len(c)
if len(b) == 0:
	while l > 2:
		k = c.pop()
		t = c.pop()
		b.append(k)
		b.append(t)
		l = l - 2
	if l == 2:
		d.append(c.pop())
else:
	while l > 1:
		k = c.pop()
		d.append(k)
		l = l - 1
print(len(c), end=' ')
print(*c)
print(len(b), end=' ')
print(*b)
print(len(d), end=' ')
print(*d)


n = int(input())
a = list(map(int, input().split()))
n1 = []
n2 = []
n3 = []
for i in range(n):
	if a[i] < 0:
		n1.append(a[i])
	if a[i] > 0:
		n2.append(a[i])
	if a[i] == 0:
		n3.append(a[i])
if len(n2) != 0:
	print(1, n1[0])
	print(len(n2), ' '.join((str(n2[i]) for i in range(len(n2)))))
	print(len(n3) + len(n1) - 1, ' '.join((str(n3[i]) for i in range(len(n3)))) + ' ' * min(len(n1) - 1, 1) + ' '.join((str(n1[i]) for i in range(1, len(n1)))))
elif len(n1) % 2 != 0:
	print(len(n1) - 2, ' '.join((str(n1[i]) for i in range(len(n1) - 2))))
	print(len(n2) + 2, ' '.join((str(n1[i]) for i in range(len(n1) - 2, len(n1)))) + ' '.join((str(n2[i]) for i in range(len(n2)))))
	print(len(n3), ' '.join((str(n3[i]) for i in range(len(n3)))))
else:
	print(1, n1[0])
	print(2, n1[1], n1[2])
	print(len(n3) + len(n1) - 3, ' '.join((str(n3[i]) for i in range(len(n3)))) + ' ' * min(1, len(n1) - 3) + ' '.join((str(n1[i]) for i in range(3, len(n1)))))


n = int(input())
a = list(map(int, input().split()))
countNeg = 0
n1 = []
n2 = []
n3 = []
for i in a:
	if i < 0:
		countNeg += 1
if countNeg == 1:
	for i in a:
		if i < 0:
			n1.append(i)
		elif i == 0:
			n3.append(i)
		else:
			n2.append(i)
elif countNeg == 2:
	for i in a:
		if i < 0 and len(n1) == 0:
			n1.append(i)
		elif i < 0 or i == 0:
			n3.append(i)
		else:
			n2.append(i)
else:
	for i in a:
		if i < 0 and len(n1) == 0:
			n1.append(i)
		elif i < 0 and len(n2) < 2:
			n2.append(i)
		else:
			n3.append(i)

def printEl(x):
	print(len(x), end=' ')
	for i in x:
		print(i, end=' ')
	print()
printEl(n1)
printEl(n2)
printEl(n3)


a = int(input())
l = list(map(int, input().split()))
d = {'+ve': [], '-ve': [], 'zero': []}
for i in l:
	if i > 0:
		d['+ve'].append(i)
	elif i < 0:
		d['-ve'].append(i)
	else:
		d['zero'].append(i)
if len(d['-ve']) % 2 == 0:
	list_of_zeros = d['zero'] + [d['-ve'][0]]
	list_of_positives = d['+ve']
	list_of_negatives = d['-ve'][1:]
else:
	list_of_zeros = d['zero']
	list_of_positives = d['+ve']
	list_of_negatives = d['-ve']
if len(list_of_positives) == 0:
	list_of_positives = list_of_negatives[1:]
	list_of_negatives = [list_of_negatives[0]]
print(len(list_of_negatives), end=' ')
for i in list_of_negatives:
	print(i, end=' ')
print()
print(len(list_of_positives), end=' ')
for i in list_of_positives:
	print(i, end=' ')
print()
print(len(list_of_zeros), end=' ')
for i in list_of_zeros:
	print(i, end=' ')


n = int(input())
nums = [int(i) for i in input().split()]
neg = [i for i in nums if i < 0]
pos = [i for i in nums if i > 0]
zero = [i for i in nums if i == 0]
if len(pos) == 0:
	pos = neg[-2:]
	neg = neg[:-2]
if len(neg) % 2 == 0:
	zero.append(neg[-1])
	neg = neg[:-1]
print(len(neg), *neg)
print(len(pos), *pos)
print(len(zero), *zero)


def array_set(array):
	array3 = list()
	negative = 0
	positive = 0
	array = sorted(array)
	a = len(array)
	i = 0
	while i < a:
		if array[i] < 0:
			negative += 1
			i += 1
		elif array[i] == 0:
			array3.append(0)
			array.remove(0)
			a -= a
			i += 1
		else:
			positive += 1
			i += 1
	if negative % 2 == 0:
		array3.append(array[0])
		array.remove(array[0])
	array1 = array[0:negative]
	array2 = array[negative:len(array)]
	if len(array2) == 0:
		array2 = array1[0:2]
		array1 = array1[2:len(array1)]
	print(len(array1), *array1)
	print(len(array2), *array2)
	print(len(array3), *array3)
n = input()
array = [int(x) for x in input().split()]
array_set(array)


array_to_string = lambda x: ' '.join([str(a) for a in x])
N = int(input())
A = list(map(int, input().split()))
neg = []
pos = []
zero = []
for a in A:
	if a < 0:
		neg.append(a)
	if a > 0:
		pos.append(a)
	if a == 0:
		zero.append(a)
if len(pos) <= 0:
	pos.append(neg.pop())
	pos.append(neg.pop())
if len(neg) % 2 == 0:
	zero.append(neg.pop())
print(len(neg), array_to_string(neg))
print(len(pos), array_to_string(pos))
print(len(zero), array_to_string(zero))


n = int(input())
array = list(map(int, input().split()))
negative_numbers = []
positive_numbers = []
zero_numbers = []
for number in array:
	if number < 0:
		negative_numbers.append(number)
	elif number > 0:
		positive_numbers.append(number)
	else:
		zero_numbers.append(number)
if len(negative_numbers) % 2 == 0:
	zero_numbers.append(negative_numbers[-1])
	negative_numbers.pop()
if len(positive_numbers) == 0:
	positive_numbers.append(negative_numbers[0])
	positive_numbers.append(negative_numbers[1])
	negative_numbers.pop(0)
	negative_numbers.pop(0)
negative_set = ' '.join(map(str, negative_numbers))
positive_set = ' '.join(map(str, positive_numbers))
zero_set = ' '.join(map(str, zero_numbers))
print('{} {}'.format(len(negative_numbers), negative_set))
print('{} {}'.format(len(positive_numbers), positive_set))
print('{} {}'.format(len(zero_numbers), zero_set))


input()
l = list(map(int, input().split()))
l1 = []
l2 = []
l3 = []
neg = 0
for e in l:
	if e < 0:
		neg += 1
neg_added = False
for e in l:
	if e < 0 and (not neg_added):
		l1.append(e)
		neg_added = True
	elif e == 0:
		l3.append(e)
	elif neg % 2 == 0 and e < 0:
		l3.append(e)
		neg -= 1
	else:
		l2.append(e)
print(len(l1), *l1)
print(len(l2), *l2)
print(len(l3), *l3)


n = int(input())
l = list(map(int, input().split()))
a = []
b = []
c = []
l.sort()
a.append(l[0])
l.remove(l[0])
if l[-1] > 0:
	b.append(l[-1])
	l.remove(l[-1])
if len(b) == 0:
	b.append(l[0])
	b.append(l[1])
	l.remove(l[0])
	l.remove(l[0])
for _ in l:
	if _ == 0:
		c.append(_)
		l.remove(_)
for __ in l:
	c.append(__)
print(len(a), end=' ')
print(*a, sep=' ')
print(len(b), end=' ')
print(*b, sep=' ')
print(len(c), end=' ')
print(*c, sep=' ')


def display(arr):
	print(len(arr), end=' ')
	for x in arr:
		print(x, end=' ')
	print()
n = int(input())
arr = [int(x) for x in input().split()]
set1 = []
set2 = []
set3 = []
for x in arr:
	if x < 0:
		set1.append(x)
	elif x > 0:
		set2.append(x)
	else:
		set3.append(x)
if len(set2) == 0 and len(set1) % 2 == 0:
	set3.append(set1[0])
	del set1[0]
	set2.append(set1[0])
	set2.append(set1[1])
	del set1[0:2]
elif len(set2) == 0 and len(set1) % 2 != 0:
	set2.append(set1[0])
	set2.append(set1[1])
	del set1[0:2]
elif len(set1) % 2 == 0:
	set3.append(set1[0])
	del set1[0]
display(set1)
display(set2)
display(set3)


n = int(input())
a = list(map(int, input().split()))
p = []
n = []
z = []
for i in a:
	if i == 0:
		z.append(0)
	elif i > 0:
		p.append(i)
	else:
		n.append(i)
if len(n) % 2 == 0:
	z.append(n[-1])
	n.pop()
if len(p) == 0:
	p.append(n[-1])
	n.pop()
	p.append(n[-1])
	n.pop()
print(len(n), *n)
print(len(p), *p)
print(len(z), *z)


_ = input()
arr = list(map(int, input().split()))
p = []
n = []
z = []
for x in arr:
	if x == 0:
		z.append(str(x))
	elif x < 0:
		n.append(str(x))
	else:
		p.append(str(x))
if len(p) == 0:
	p.append(n.pop())
	p.append(n.pop())
if len(n) % 2 == 0:
	z.append(n.pop())
print(len(n), ' '.join(n))
print(len(p), ' '.join(p))
print(len(z), ' '.join(z))


t = int(input())
a = list(map(int, input().split()))
b = []
c = []
d = []
for i in a:
	if i < 0:
		b.append(i)
		a.remove(i)
		break
for i in a:
	if i > 0:
		c.append(i)
		a.remove(i)
		break
a.sort()
if len(c) == 0:
	c.append(a[0])
	c.append(a[1])
	a.pop(0)
	a.pop(0)
print(len(b), *b)
print(len(c), *c)
print(len(a), *a)


n = int(input())
arrays = [[], [], []]
for i in input().split():
	if i[0] == '-':
		arrays[0].append(i)
	elif i[0] == '0':
		arrays[2].append(i)
	else:
		arrays[1].append(i)
if not len(arrays[0]) % 2:
	arrays[2].append(arrays[0][-1])
	del arrays[0][-1]
if len(arrays[1]) == 0:
	arrays[1].append(arrays[0][-1])
	del arrays[0][-1]
	arrays[1].append(arrays[0][-1])
	del arrays[0][-1]
[print(len(i), ' '.join(i)) for i in arrays]


n = int(input().strip())
array = list(map(int, input().strip().split()))
small = {x for x in array if x < 0}
zero = {0}
large = {x for x in array if x > 0}
if len(small) % 2 == 0:
	zero.add(small.pop())
if len(large) < 1:
	large.add(small.pop())
	large.add(small.pop())
print(len(small), *small)
print(len(large), *large)
print(len(zero), *zero)


n = int(input())
negativos = list()
positivos = list()
nulos = list()
l = input()
l = l.split()
for item in l:
	num = int(item)
	if num > 0:
		positivos.append(num)
	elif num < 0:
		negativos.append(num)
	else:
		nulos.append(0)
if len(negativos) % 2 == 0:
	nulos.append(negativos[0])
	negativos = negativos[1:]
if len(positivos) == 0:
	positivos.append(negativos[0])
	positivos.append(negativos[1])
	negativos = negativos[2:]
print(len(negativos), end=' ')
for item in negativos:
	print(item, end=' ')
print()
print(len(positivos), end=' ')
for item in positivos:
	print(item, end=' ')
print()
print(len(nulos), end=' ')
for item in nulos:
	print(item, end=' ')


n = int(input())
numeros = list(map(int, input().split()))
neg = []
pos = []
zero = []
for x in numeros:
	if x < 0:
		neg.append(x)
	elif x > 0:
		pos.append(x)
	else:
		zero.append(x)
if not len(neg) & 1:
	zero.append(neg.pop())
if len(pos) == 0:
	pos.append(neg.pop())
	pos.append(neg.pop())
print(len(neg), ' '.join(list(map(str, neg))))
print(len(pos), ' '.join(list(map(str, pos))))
print(len(zero), ' '.join(list(map(str, zero))))


N = int(input())
A = list(map(int, input().strip().split()))
n1 = []
n2 = []
n3 = []
for (i, a) in enumerate(A):
	if a == 0:
		n3 += [a]
	elif a < 0:
		n1 += [a]
	else:
		n2 += [a]
if len(n2) == 0:
	n2 += [n1[-1]]
	n1.pop()
	n2 += [n1[-1]]
	n1.pop()
if len(n1) % 2 == 0:
	n3 += [n1[-1]]
	n1.pop()
print(len(n1), *n1)
print(len(n2), *n2)
print(len(n3), *n3)


n = input()
m = list(map(int, input().split()))
(z, n, p) = ([], [], [])
for i in m:
	if i > 0:
		p += [i]
	elif i < 0:
		n += [i]
	else:
		z += [i]
if len(n) % 2 == 0:
	z += [n.pop()]
if len(p) == 0:
	p += [n.pop(), n.pop()]
print(len(n), *n)
print(len(p), *p)
print(len(z), *z)


n = int(input())
a = list(map(int, input().split()))
a.sort()
pos = len([x for x in a if x > 0])
neg = len([x for x in a if x < 0])
print(1, a[0])
a.pop(0)
if pos == 0:
	print(2, a[0], a[1])
	a.pop(0)
	a.pop(0)
else:
	print(1, a[-1])
	a.pop(-1)
if len(a) <= 1:
	print(1, 0)
else:
	print(len(a), *a)


n = int(input())
list3 = map(int, input().split())
list3 = list(list3)
list3.sort()
list1 = [list3.pop(0)]
list2 = list3[-1] > 0 and [list3.pop()] or [list3.pop(0), list3.pop(0)]
for x in (list1, list2, list3):
	print(len(x), ' '.join(map(str, x)))


n = int(input())
a = list(map(int, input().split()))
count_neg = 0
count_pos = 0
for el in a:
	if el < 0:
		count_neg += 1
	elif el > 0:
		count_pos += 1
(neg, pos, zero) = ([], [], [])
(j, k) = (0, 0)
if count_pos == 0:
	for i in range(n):
		if a[i] < 0 and j < 2:
			pos.append(a[i])
			count_neg -= 1
			j += 1
		elif a[i] < 0 and k < 1:
			neg.append(a[i])
			count_neg -= 1
			k += 1
		else:
			zero.append(a[i])
else:
	for i in range(n):
		if a[i] > 0:
			pos.append(a[i])
		elif a[i] < 0 and k < 1:
			neg.append(a[i])
			count_neg -= 1
			k += 1
		else:
			zero.append(a[i])
print(len(neg), *neg)
print(len(pos), *pos)
print(len(zero), *zero)


N = int(input())
A = input().split()
for i in range(0, len(A)):
	A[i] = int(A[i])
X = []
Y = []
Z = []
for i in range(0, len(A)):
	if A[i] == 0:
		Z.append(A[i])
	elif A[i] > 0:
		Y.append(A[i])
	elif A[i] < 0:
		X.append(A[i])
if not Y:
	Y.append(X[-1])
	Y.append(X[-2])
	X = X[:-1]
	X = X[:-1]
if len(X) % 2 == 1:
	print(str(len(X)), end=' ')
	for i in range(0, len(X) - 1):
		print(str(X[i]), end=' ')
	print(str(X[-1]))
else:
	Z.append(X[-1])
	X = X[:-1]
	print(str(len(X)), end=' ')
	for i in range(0, len(X) - 1):
		print(str(X[i]), end=' ')
	print(str(X[-1]))
print(str(len(Y)), end=' ')
for i in range(0, len(Y) - 1):
	print(str(Y[i]), end=' ')
print(str(Y[-1]))
print(str(len(Z)), end=' ')
for i in range(0, len(Z) - 1):
	print(str(Z[i]), end=' ')
print(str(Z[-1]))


import math
from collections import defaultdict, Counter, deque
INF = float('inf')

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def isPrime(n):
	if n <= 1:
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

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 vars():
	return map(int, input().split())

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

def main():
	m = int(input())
	arr = array()
	n = []
	o = []
	p = []
	for i in range(m):
		if arr[i] < 0:
			n.append(arr[i])
		elif arr[i] == 0:
			o.append(arr[i])
		else:
			p.append(arr[i])
	if len(p) == 0 and len(n) > 2:
		p.append(n[0])
		n.pop(0)
		p.append(n[0])
		n.pop(0)
	elif len(p) == 0 and len(o) > 1:
		p.append(o[0])
		o.pop(0)
	if len(n) % 2 == 0:
		o.append(n[-1])
		n.pop(-1)
	print(len(n), *n)
	print(len(p), *p)
	print(len(o), *o)
t = 1
for _ in range(t):
	main()


n = int(input())
nums = [int(x) for x in input().split()]
gr1 = []
gr2 = []
gr3 = []
if sum([x <= 0 for x in nums]) == n:
	cnt1 = 2
	cnt2 = 1
	for ch in nums:
		if ch == 0:
			gr3.append(ch)
		elif cnt1 > 0:
			gr1.append(ch)
			cnt1 -= 1
		elif cnt2 > 0:
			gr2.append(ch)
			cnt2 -= 1
		else:
			gr3.append(ch)
else:
	cnt1 = 1
	cnt2 = 1
	for ch in nums:
		if ch == 0:
			gr3.append(ch)
		elif ch > 0 and cnt1 > 0:
			gr1.append(ch)
			cnt1 -= 1
		elif ch < 0 and cnt2 > 0:
			gr2.append(ch)
			cnt2 -= 1
		else:
			gr3.append(ch)
print(len(gr2), end=' ')
print(' '.join(map(str, gr2)))
print(len(gr1), end=' ')
print(' '.join(map(str, gr1)))
print(len(gr3), end=' ')
print(' '.join(map(str, gr3)))


n = int(input())
lis = [int(x) for x in input().split()]
lis.sort()
a = lis[0]
del lis[0]
b = [x for x in lis if x != 0]
neg = 0
for x in b:
	if x < 0:
		neg += 1
c = [x for x in lis if x == 0]
if neg % 2 == 1:
	c.append(b[0])
	del b[0]
print(1, a)
print(len(b), *b)
print(len(c), *c)


t = int(input())
x = list(map(int, input().split()))
p = []
n = []
z = []
for i in range(t):
	if x[i] > 0:
		p.append(x[i])
	elif x[i] == 0:
		z.append(0)
	else:
		n.append(x[i])
if len(n) % 2 != 0:
	print(1, n[0])
	print(len(p) + len(n) - 1, *p + n[1:])
	print(len(z), *z)
elif len(p) == 0:
	print(1, n[0])
	print(2, n[1], n[2])
	print(len(z) + len(n) - 3, *z + n[3:])
else:
	print(1, n[0])
	print(len(p), *p)
	print(len(z) + len(n) - 1, *z + n[1:])


n = int(input())
a = [int(i) for i in input().split()]
l = []
b = []
c = []
d = []
s = []
for i in range(0, len(a)):
	if a[i] < 0:
		l.append(a[i])
for i in range(0, len(a)):
	if a[i] > 0:
		s.append(a[i])
if len(l) % 2 != 0:
	d.append(0)
	a.remove(0)
	b.append(l[0])
	l.remove(l[0])
	c = c + l
	c = c + s
elif len(l) % 2 == 0:
	d.append(0)
	a.remove(0)
	d.append(l[0])
	l.remove(l[0])
	b.append(l[0])
	l.remove(l[0])
	c = c + s
	c = c + l
b.insert(0, len(b))
c.insert(0, len(c))
d.insert(0, len(d))
print(*b)
print(*c)
print(*d)


n = int(input())
arr_input = list(map(int, input().split()))
arr_1 = []
arr_2 = []
arr_3 = []
count = 0
for i in range(n):
	if arr_input[i] == 0:
		arr_3.append(arr_input[i])
	if arr_input[i] < 0:
		arr_1.append(arr_input[i])
		count += 1
	if arr_input[i] > 0:
		arr_2.append(arr_input[i])
if count % 2 == 0:
	temp = arr_1.pop()
	arr_3.append(temp)
if len(arr_1) == 0:
	temp_1 = arr_2.pop()
	arr_1.append(temp_1)
	temp_2 = arr_2.pop()
	arr_1.append(temp_2)
if len(arr_2) == 0:
	temp_1 = arr_1.pop()
	arr_2.append(temp_1)
	temp_2 = arr_1.pop()
	arr_2.append(temp_2)
print(len(arr_1), end=' ')
for i in range(len(arr_1)):
	print(arr_1[i], end=' ')
print('\r')
print(len(arr_2), end=' ')
for i in range(len(arr_2)):
	print(arr_2[i], end=' ')
print('\r')
print(len(arr_3), end=' ')
for i in range(len(arr_3)):
	print(arr_3[i], end=' ')


n = int(input())
a = list(map(int, input().split(' ')))
s1 = []
s2 = []
s3 = []
for i in range(n):
	if a[i] < 0:
		s1.append(a[i])
	elif a[i] > 0:
		s2.append(a[i])
	else:
		s3.append(0)
if len(s1) % 2 == 0:
	x = s1[-1]
	s1.pop()
	s3 = [x] + s3
if len(s2) == 0:
	s2 = s1[0:2]
	s1 = s1[2:]
print(len(s1), end=' ')
for i in range(len(s1)):
	print(s1[i], end=' ')
print()
print(len(s2), end=' ')
for i in range(len(s2)):
	print(s2[i], end=' ')
print()
print(len(s3), end=' ')
for i in range(len(s3)):
	print(s3[i], end=' ')
print()


def read_int():
	return int(input())

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

def print_nums(nums):
	print(' '.join(map(str, nums)))
n = read_int()
nums = read_ints()
neg = []
pos = []
zero = []
for x in nums:
	if x < 0:
		neg.append(x)
	elif x > 0:
		pos.append(x)
	else:
		zero.append(x)
for i in range(2, len(neg), 2):
	pos.extend(neg[i - 1:i + 1])
if len(neg) % 2 == 0:
	zero.append(neg[-1])
del neg[1:]
neg.insert(0, len(neg))
pos.insert(0, len(pos))
zero.insert(0, len(zero))
print_nums(neg)
print_nums(pos)
print_nums(zero)


no = input()
nos = input()
given = nos.split()
given_no = [int(i) for i in given]
third = []
negative = []
first = []
second = []
for a in given_no:
	if a == 0:
		third.append(a)
	elif a > 0:
		second.append(a)
	else:
		negative.append(a)
first.append(negative[0])
if (len(negative) - 1) % 2 == 0:
	for a in negative[1:]:
		second.append(a)
else:
	for b in negative[2:]:
		second.append(b)
	third.append(negative[1])
q = [first, second, third]
for i in q:
	print(len(i), end=' ')
	for a in i:
		print(a, end=' ')


def printList(list):
	print(len(list), end=' ')
	for num in list:
		print(num, end=' ')
	print()
n = int(input())
ary = [int(ch) for ch in input().split()]
dict = {'pos': [], 'neg': [], 'zero': []}
for num in ary:
	if num > 0:
		dict['pos'].append(num)
	elif num < 0:
		dict['neg'].append(num)
	else:
		dict['zero'].append(num)
firstSet = []
secondSet = []
thirdSet = []
if len(dict['pos']) > 0:
	list = dict['pos']
	firstSet.append(list[0])
	for num in list[1:]:
		thirdSet.append(num)
	secondSet.append(dict['neg'][0])
	for num in dict['neg'][1:]:
		thirdSet.append(num)
else:
	list = dict['neg']
	firstSet.append(list[0])
	firstSet.append(list[1])
	secondSet.append(list[2])
	for num in list[3:]:
		thirdSet.append(num)
list = dict['zero']
for num in list:
	thirdSet.append(num)
printList(secondSet)
printList(firstSet)
printList(thirdSet)


input()
a = list(map(int, input().split()))
s = [[], [], []]
for i in a:
	if i < 0:
		s[0] += [str(i)]
	elif i > 0:
		s[1] += [str(i)]
	else:
		s[2] += [str(i)]
if len(s[1]) == 0:
	s[1].extend(s[0][:2])
	s[0] = s[0][2:]
if len(s[0]) % 2 == 0:
	s[2].append(s[0][0])
	s[0] = s[0][1:]
for l in s:
	print(len(l), ' '.join(l))


n = int(input())
a = list(map(int, input().split()))
(pos, neg, zer) = ([], [], [])
for i in range(0, n):
	if a[i] > 0:
		pos.append(a[i])
	elif a[i] < 0:
		neg.append(a[i])
	elif a[i] == 0:
		zer.append(a[i])
if len(pos) == 0:
	for i in range(0, 2):
		a = neg.pop()
		pos.append(a)
if len(neg) % 2 == 0:
	a = neg.pop()
	zer.append(a)
print(len(neg), end=' ')
for i in range(0, len(neg)):
	print(neg[i], end=' ')
print()
print(len(pos), end=' ')
for i in range(0, len(pos)):
	print(pos[i], end=' ')
print()
print(len(zer), end=' ')
for i in range(0, len(zer)):
	print(zer[i], end=' ')
print()


n = int(input())
l = list(map(int, input().split()))
(x, z, y) = ([], [], [])
(a, b, c) = (0, 0, 0)
for i in range(n):
	if l[i] < 0:
		x.append(l[i])
		a = a + 1
	elif l[i] > 0:
		y.append(l[i])
		b = b + 1
	else:
		z.append(l[i])
		c = c + 1
if b == 0:
	y = y + x[:2]
	x = x[2:]
if a % 2 == 0:
	z = z + x[:1]
	x = x[1:]
print(len(x), *x)
print(len(y), *y)
print(len(z), *z)


import sys
input = sys.stdin.readline
x = int(input())
(*li,) = map(int, input().split())
li.sort()
a = li.index(0)
if a % 2:
	print(1, li[0])
	li.remove(0)
	print(x - 2, *li[1:])
	print(1, 0)
else:
	print(1, li[0])
	li.remove(0)
	print(x - 3, *li[2:])
	print(2, 0, li[1])


n = int(input())
arr = list(map(int, input().split()))
(f, s, t) = ([], [], [])
for elm in arr:
	if elm < 0:
		f.append(elm)
	elif elm > 0:
		s.append(elm)
	else:
		t.append(elm)
if len(f) % 2 == 0:
	t.append(f.pop())
if len(s) == 0:
	s.append(f.pop())
	s.append(f.pop())

def printArray(a):
	print(len(a), end=' ')
	for elm in a:
		print(elm, end=' ')
	print()
printArray(f)
printArray(s)
printArray(t)


n = int(input())
a = input().split(' ')
pos = []
neg = []
z = []
for i in range(n):
	a[i] = int(a[i])
	if a[i] < 0:
		neg.append(a[i])
	elif a[i] > 0:
		pos.append(a[i])
	else:
		z.append(a[i])
if len(pos) == 0:
	pos.append(neg[0])
	neg.pop(0)
	pos.append(neg[0])
	neg.pop(0)
if len(neg) % 2 == 0:
	z.append(neg[0])
	neg.pop(0)
print(len(neg), end=' ')
for i in neg:
	print(i, end=' ')
print()
print(len(pos), end=' ')
for i in pos:
	print(i, end=' ')
print()
print(len(z), end=' ')
for i in z:
	print(i, end=' ')
print()


n = int(input())
lst = [int(i) for i in input().split()]
negative = [i for i in lst if i < 0]
positive = [i for i in lst if i > 0]
zeros = lst.count(0)
print(1, negative[0])
(elem, negative) = (0, negative[1:])
if len(negative) & 1 == 0:
	print(len(negative) + len(positive), *negative, *positive)
else:
	(elem, negative) = (negative[0], negative[1:])
	print(len(negative) + len(positive), *negative, *positive)
if elem:
	print(str(zeros + 1) + ' 0' * zeros + ' ', elem)
else:
	print(str(zeros) + ' 0' * zeros)


n = int(input())
positive = []
negative = []
aux = list(map(int, input().split()))
for x in aux:
	if x > 0:
		positive.append(x)
	if x < 0:
		negative.append(x)
set1 = []
set2 = []
set3 = []
set1 += [negative.pop()]
set3 += [0]
if len(positive) == 0:
	set2 += [negative.pop()]
	set2 += [negative.pop()]
set2 += positive
set3 += negative
for setN in [set1, set2, set3]:
	print('{l} {s}'.format(l=len(setN), s=' '.join(list(map(str, setN)))))


n = int(input())
arr = sorted(list(map(int, input().split())), reverse=True)
if arr[0] != 0:
	print('1 ' + str(arr[-1]))
	print('1 ' + str(arr[0]))
	print(n - 2, *arr[1:-1])
else:
	print('1 ' + str(arr[1]))
	print('2 ' + str(arr[-1]) + ' ' + str(arr[-2]))
	print(n - 3, 0, *arr[2:-2])


n = int(input())
arr = list(map(int, input().split()))
(pos, neg, zero) = ([], [], [])
for i in arr:
	if i == 0:
		zero.append(0)
	elif i > 0:
		pos.append(i)
	else:
		neg.append(i)
if len(neg) % 2 == 0:
	zero.append(neg.pop())
if len(pos) == 0:
	pos.append(neg.pop())
	pos.append(neg.pop())
print(len(neg), end=' ')
print(*neg, end=' ')
print()
print(len(pos), end=' ')
print(*pos, end=' ')
print()
print(len(zero), end=' ')
print(*zero, end=' ')
print()


import io
import os

def main():
	n = int(input())
	a = list(map(int, input().split()))
	l1 = []
	l2 = []
	l3 = []
	for val in a:
		if val < 0:
			l1.append(val)
		elif val > 0:
			l2.append(val)
		else:
			l3.append(val)
	if len(l2) == 0:
		l2.append(l1.pop())
		l2.append(l1.pop())
	if len(l1) % 2 == 0:
		l3.append(l1.pop())
	print(len(l1), *l1)
	print(len(l2), *l2)
	print(len(l3), *l3)
main()


n = int(input())
ls = list(map(int, input().split()))
negative = []
positive = []
zeros = []
for i in ls:
	if i < 0:
		negative.append(i)
	elif i == 0:
		zeros.append(i)
	else:
		positive.append(i)
if len(positive) == 0:
	positive.append(negative.pop())
	positive.append(negative.pop())
if len(negative) % 2 == 0:
	zeros.append(negative.pop())
print(len(negative), *negative, sep=' ')
print(len(positive), *positive, sep=' ')
print(len(zeros), *zeros, sep=' ')


n = int(input())
a = [int(x) for x in input().split()]
n1 = []
n2 = []
n3 = []
for i in range(len(a)):
	if a[i] < 0:
		n1.append(a[i])
		a.pop(i)
		break
for i in range(len(a)):
	if a[i] == 0:
		n3.append(a[i])
		a.pop(i)
		break
two = []
for i in range(len(a)):
	if a[i] < 0:
		two.append(a[i])
		if len(two) == 2:
			n2 = n2 + two
			two = []
	else:
		n2.append(a[i])
if len(two) != 0:
	n3 = n3 + two
str1 = str(len(n1))
for x in n1:
	str1 = str1 + ' ' + str(x)
str2 = str(len(n2))
for x in n2:
	str2 = str2 + ' ' + str(x)
str3 = str(len(n3))
for x in n3:
	str3 = str3 + ' ' + str(x)
print(str1)
print(str2)
print(str3)


(l, l1, l2, l3) = [list(map(int, list(input() * 0) + input().split(' '))), [], [], []]
for elem in l:
	if elem > 0:
		l2.append(elem)
	elif elem < 0 and len(l1) == 0:
		l1.append(elem)
	else:
		l3.append(elem)
if len(l2) == 0:
	l3.sort()
	l2.append(l3.pop(0))
	l2.append(l3.pop(0))
for lis in [l1, l2, l3]:
	print(len(lis), end='')
	for e in lis:
		print(' ' + str(e), end='')
	print()


n = int(input())
inp = sorted(list(map(int, input().split())))
print(1, inp[0])
if inp[-1] > 0:
	print(1, inp[-1])
	print(n - 2, end=' ')
	for i in inp[1:n - 1]:
		print(i, end=' ')
else:
	print(2, inp[1], inp[2])
	print(n - 3, end=' ')
	for i in inp[3:]:
		print(i, end=' ')


n = int(input())
a = [int(x) for x in input().split()]
nega = 0
cnt = 0
for i in a:
	if i < 0:
		nega += 1
x = []
y = []
z = []
for i in a:
	if i < 0 and len(x) == 0:
		x.append(i)
		nega -= 1
	elif i == 0:
		z.append(i)
	elif i > 0:
		y.append(i)
	elif nega >= 2 and cnt != 2:
		y.append(i)
		cnt += 1
	else:
		z.append(i)
print(len(x), *x)
print(len(y), *y)
print(len(z), *z)


n = int(input())
x = list(map(int, input().split()))
x.sort()
for i in range(x.count(0)):
	x.remove(0)
	x.append(0)
(lo, go, zo) = ([], [], [])
lo.append(x[0])
x.remove(x[0])
n_calc = lambda : filter(lambda a: True if a < 0 else False, x)
negatives = list(n_calc())
n_count = len(negatives)
if n_count % 2 == 0:
	for i in negatives:
		go.append(i)
		x.remove(i)
else:
	zo.append(x[0])
	negatives.remove(x[0])
	x.remove(x[0])
	for i in negatives:
		go.append(i)
		x.remove(i)
for i in x:
	if i == 0:
		zo.append(i)
	else:
		go.append(i)
x_print = lambda l: print(len(l), ' '.join(list(map(str, l))))
x_print(lo)
x_print(go)
x_print(zo)


n = int(input())
a = list(map(int, input().split()))
n1 = 0
list1 = []
n2 = 0
list2 = []
n3 = 0
list3 = []
neg1 = 0
neg2 = 0
count = 0
for i in range(n):
	if a[i] == 0:
		n3 += 1
		list3.append(a[i])
	elif a[i] > 0:
		n2 += 1
		list2.append(a[i])
	elif count == 0:
		count += 1
		neg1 = a[i]
	elif count == 1:
		count += 1
		neg2 = a[i]
	else:
		n2 += 2
		list2.append(neg1)
		list2.append(neg2)
		count = 1
		neg1 = a[i]
if count == 1:
	n1 += 1
	list1.append(neg1)
else:
	n1 += 1
	list1.append(neg1)
	n3 += 1
	list3.append(neg2)
print(n1, end=' ')
for i in range(n1):
	print(list1[i], end=' ')
print()
print(n2, end=' ')
for i in range(n2):
	print(list2[i], end=' ')
print()
print(n3, end=' ')
for i in range(n3):
	print(list3[i], end=' ')


n = int(input())
a = list(map(int, input().split()))
positive = []
negative = []
zero = []
for i in range(0, n):
	if a[i] == 0:
		zero.append(a[i])
	if a[i] > 0:
		positive.append(a[i])
	if a[i] < 0:
		negative.append(a[i])
if len(negative) % 2 != 0:
	m = negative[0]
	x = [m]
	del negative[0]
	y = positive + negative
	z = zero
else:
	m = negative[0]
	x = [m]
	n = negative[1]
	p = [n]
	z = zero + p
	del negative[0]
	del negative[0]
	y = positive + negative
x.insert(0, 1)
y.insert(0, len(y))
z.insert(0, len(z))
print(*x)
print(*y)
print(*z)


n = int(input())
a = list(map(int, input().split()))
a.sort()
negative = []
zero = 0
pos = []
for i in a:
	if i < 0:
		negative.append(i)
	elif i == 0:
		zero += 1
	else:
		pos.append(i)
zero = [0 for _ in range(zero)]
if not len(pos):
	pos.append(negative[0])
	negative.pop(0)
	pos.append(negative[0])
	negative.pop(0)
if not len(negative) & 1:
	zero.append(negative[0])
	negative.pop(0)
print(len(negative), *negative)
print(len(pos), *pos)
print(len(zero), *zero)


n = int(input())
a = [int(i) for i in input().split()]
bz = 0
for i in a:
	if i > 0:
		bz += 1
if bz > 0:
	bb = []
	kk = []
	for i in range(n):
		if a[i] > 0:
			bb.append(a[i])
			a.pop(i)
			break
	for i in range(n):
		if a[i] < 0:
			kk.append(a[i])
			a.pop(i)
			break
else:
	bb = []
	kk = []
	i = 0
	m = 0
	while m != 2:
		if a[i] < 0:
			bb.append(a[i])
			a.pop(i)
			m += 1
		i += 1
	for i in range(n):
		if a[i] < 0:
			kk.append(a[i])
			a.pop(i)
			break
lkk = len(kk)
lbb = len(bb)
la = len(a)
bas = [lbb]
kas = [lkk]
aas = [la]
for i in range(lkk):
	kas.append(kk[i])
for i in range(lbb):
	bas.append(bb[i])
for i in range(la):
	aas.append(a[i])
for i in kas:
	print(i, end=' ')
print()
for i in bas:
	print(i, end=' ')
print()
for i in aas:
	print(i, end=' ')


k = int(input())
a = list(map(int, input().split()))
a.sort()
(n, z, p) = (0, 0, 0)
for i in range(k):
	if a[i] < 0:
		n += 1
	elif a[i] == 0:
		z += 1
	else:
		p += 1
for i in range(k):
	if a[i] == 0:
		zi = i
		break
for i in range(k):
	if a[i] > 0:
		pi = i
		break
if n % 2 != 0:
	if p > 0:
		print(n, *a[:zi])
		print(p, *a[pi:])
		print(z, *a[zi:pi])
	else:
		print(n - 2, *a[:zi - 2])
		print(2, *a[zi - 2:zi])
		print(z, *a[zi:])
elif p > 0:
	print(n - 1, *a[:zi - 1])
	print(p, *a[pi:])
	print(z + 1, *a[zi - 1:pi])
else:
	print(1, a[0])
	print(2, *a[1:3])
	print(z + n - 3, *a[3:])


n = int(input())
a = list(map(int, input().split()))
n = len(a)
b = list()
c = list()
d = list()
e = list()
count1 = 0
count2 = 0
count3 = 0
for i in range(n):
	if a[i] < 0:
		b.append(a[i])
		count1 = count1 + 1
	if a[i] > 0:
		c.append(a[i])
		count2 = count2 + 1
	if a[i] == 0:
		d.append(a[i])
		count3 = count3 + 1
e.append(b[0])
if count1 >= 3:
	for k in range(1, 3):
		c.append(b[k])
		count2 = count2 + 1
	for k in range(3, count1):
		d.append(b[k])
		count3 = count3 + 1
elif count1 == 2:
	d.append(b[1])
	count3 = count3 + 1
print(1, *e)
print(count2, *c)
print(count3, *d)


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
negative = [arr[0]]
arr.pop(0)
neg_num = arr.index(0)
positive = []
zero = []
if neg_num % 2 == 0:
	positive = arr[:neg_num]
	zero = arr[neg_num:]
else:
	positive = arr[:neg_num - 1]
	zero = arr[neg_num - 1:]
if len(positive) == 0:
	positive = [zero[-1]]
	zero.pop()
print(len(negative), end=' ')
for x in range(len(negative)):
	print(negative[x], end=' ')
print()
print(len(positive), end=' ')
for x in range(len(positive)):
	print(positive[x], end=' ')
print()
print(len(zero), end=' ')
for x in range(len(zero)):
	print(zero[x], end=' ')


class Array:

	def __init__(self):
		n = int(input())
		myList = list(map(int, input().split()))
		self.minus = []
		self.plus = []
		self.zero = []
		for num in myList:
			if num < 0:
				self.minus.append(num)
			elif num > 0:
				self.plus.append(num)
			else:
				self.zero.append(num)

	def calculate(self):
		print('1', self.minus[0], sep=' ', end='\n')
		self.minus.pop(0)
		if len(self.plus) > 0:
			print(len(self.plus), end=' ', sep='')
			print(*self.plus)
			print(len(self.minus) + len(self.zero), end=' ', sep='')
			print(*self.minus, end=' ')
			print(*self.zero)
		elif len(self.minus) % 2 == 1:
			z = self.minus[0]
			self.minus.pop(0)
			print(len(self.minus), end=' ', sep='')
			print(*self.minus, end='\n')
			print(len(self.zero) + 1, end=' ', sep='')
			print(z, *self.zero, sep=' ')
		else:
			print(len(self.minus), end=' ', sep='')
			print(*self.minus, end='\n')
			print(len(self.zero), end=' ', sep='')
			print(*self.zero, sep=' ')
inp = Array()
inp.calculate()


n = int(input())
x = list(map(int, input().split()))
x.sort()
n1 = 0
n2 = 0
n3 = 0
nega = []
i = 0
while len(nega) < 3 and x[i] < 0:
	if x[i] < 0:
		nega.append(x[i])
		x.remove(x[i])
if len(nega) == 3:
	print('1 ' + str(nega[0]))
	print('2 ' + str(nega[1]) + ' ' + str(nega[2]))
	leng = len(x)
	x = list(map(str, x))
	x = ' '.join(x)
	print(str(leng) + ' ' + x)
else:
	print('1 ' + str(nega[0]))
	len1 = len(x) + 1 - 1
	x = list(filter(None, x))
	x = list(map(str, x))
	leng = len(x)
	len2 = abs(len1 - leng)
	x1 = x[0]
	x.remove(x[0])
	x = ' '.join(x)
	print('1 ' + x1)
	if len(nega) == 2:
		print(str(len2 + len(x) + 1) + ' ' + '0 ' * len2 + str(nega[1]) + ' ' + x)
	else:
		print(str(len2 + len(x)) + ' ' + '0 ' * len2 + x)


num = int(input())
arr = list(map(int, input().split()))
(n, p, z) = ([], [], [])
z.append(0)
nc = 0
pc = 0
for i in range(num):
	if arr[i] < 0:
		nc += 1
		n.append(arr[i])
	if arr[i] > 0:
		pc += 1
		p.append(arr[i])
if nc % 2 == 0:
	z.append(n[len(n) - 1])
	n.remove(n[len(n) - 1])
if nc >= 3:
	p.append(n[len(n) - 1])
	p.append(n[len(n) - 2])
	n.remove(n[len(n) - 1])
	n.remove(n[len(n) - 1])
(n1, z1, p1) = ('', '', '')
print(len(n), n1.join([str(elem) + ' ' for elem in n]))
print(len(p), p1.join([str(elem) + ' ' for elem in p]))
print(len(z), z1.join([str(elem) + ' ' for elem in z]))


n = int(input())
l = list(map(int, input().split()))
one = []
two = []
three = []
for i in l:
	if i < 0:
		one.append(i)
	elif i > 0:
		two.append(i)
	else:
		three.append(i)
if len(one) % 2 == 0:
	a = one.pop()
	three.append(a)
if len(two) == 0:
	a = one.pop(0)
	b = one.pop(0)
	two.append(a)
	two.append(b)
print(len(one), end=' ')
for i in one:
	print(i, end=' ')
print('\n')
print(len(two), end=' ')
for i in two:
	print(i, end=' ')
print('\n')
print(len(three), end=' ')
for i in three:
	print(i, end=' ')


n = int(input())
number = list(map(int, input().split()))
negative = []
possitive = []
zero = []
count = 0
for i in number:
	if i < 0:
		negative.append(i)
	elif i > 0:
		possitive.append(i)
	else:
		zero.append(i)
if len(possitive) == 0:
	possitive.append(negative.pop())
	possitive.append(negative.pop())
if len(negative) % 2 == 0:
	zero.append(negative.pop())
print(len(negative), *negative, sep=' ')
print(len(possitive), *possitive, sep=' ')
print(len(zero), *zero, sep=' ')


n = int(input())
x = input()
x = x.split()
for i in range(n):
	x[i] = int(x[i])
a1 = list()
a2 = list()
a3 = list()
for i in range(len(x)):
	if x[i] < 0:
		a1.append(x[i])
	elif x[i] > 0:
		a2.append(x[i])
	else:
		a3.append(x[i])
if len(a1) % 2 == 0 and len(a1) != 0:
	a3.append(a1.pop(len(a1) - 1))
if len(a2) == 0:
	a2.append(a1.pop(len(a1) - 1))
	a2.append(a1.pop(len(a1) - 1))
s1 = ''
s2 = ''
s3 = ''
for i in range(len(a1)):
	s1 += str(a1[i]) + ' '
print(len(a1), s1)
for i in range(len(a2)):
	s2 += str(a2[i]) + ' '
print(len(a2), s2)
for i in range(len(a3)):
	s3 += str(a3[i]) + ' '
print(len(a3), s3)


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

def index(ls, n):
	for i in range(n):
		if ls[i] == 0:
			return i
soduong = n - index(ls, n) - 1
if soduong > 0:
	print(1, ls[0])
	print(1, ls[len(ls) - 1])
	print(len(ls) - 2, end=' ')
	i = 1
	while i < len(ls) - 1:
		print(ls[i], end=' ')
		i += 1
else:
	print(1, ls[0])
	print(2, ls[1], ls[2])
	i = 3
	print(len(ls) - 3, end=' ')
	while i < len(ls):
		print(ls[i], end=' ')
		i += 1


n = int(input())
arr = list(map(int, input().split()))
n1 = list(filter(lambda x: x < 0, arr))
n2 = list(filter(lambda x: x > 0, arr))
z = 0
print('1', end=' ')
print(n1[0])
if len(n2) > 0:
	print(len(n2), end=' ')
	for x in n2:
		print(x, end=' ')
	print()
else:
	z = 1
	print('2', end=' ')
	print(n1[1], n1[2], end=' ')
	print()
if z == 1:
	print(n - 3, end=' ')
	for i in range(3, len(n1)):
		print(n1[i], end=' ')
	print('0')
else:
	print(n - 1 - len(n2), end=' ')
	for i in range(1, len(n1)):
		print(n1[i], end=' ')
	print('0')


ln = int(input())
(set1, set2, set3) = ([], [], [])
(positive, negative) = ([], [])
for x in input().rsplit():
	x = int(x)
	if x == 0:
		set3.append(x)
	elif x > 0:
		positive.append(x)
	else:
		negative.append(x)
set1.append(negative.pop(0))
flag = 0
if len(negative) >= 2:
	set2.append(negative.pop(0))
	set2.append(negative.pop(0))
	flag = 1
for x in range(len(negative)):
	set3.append(negative[x])
if flag == 0:
	set2.append(positive.pop(0))
set3 = set3 + positive
set1.sort()
set2.sort()
set3.sort()
set1 = [len(set1)] + set1
set2 = [len(set2)] + set2
set3 = [len(set3)] + set3
for x in set1:
	print(x, end=' ')
print()
for x in set2:
	print(x, end=' ')
print()
for x in set3:
	print(x, end=' ')


n = int(input())
f = [int(x) for x in input().split()]
p = []
n = []
z = 0
for i in range(len(f)):
	if f[i] > 0:
		p.append(f[i])
	elif f[i] < 0:
		n.append(f[i])
if len(p) > 0:
	print('1 {}'.format(n[0]))
	print('1 {}'.format(p[0]))
	print(len(p) + len(n) - 1, end='')
	print(' 0', end='')
	n = n[1:]
	p = p[1:]
	for i in n:
		print(' {}'.format(i), end='')
	for i in p:
		print(' {}'.format(i), end='')
	print()
else:
	print('1 {}'.format(n[0]))
	print('2 {} {}'.format(n[1], n[2]))
	print(len(n) - 2, end='')
	print(' 0', end='')
	n = n[3:]
	for i in n:
		print(' {}'.format(i), end='')
	print()


def main():
	n = int(input())
	a = set(map(int, input().split()))
	print(1, min(a))
	a -= {min(a)}
	if max(a) > 0:
		s = {max(a)}
		a -= s
	else:
		s = {min(a)}
		a -= s
		s.add(min(a))
		a -= {min(a)}
	print(len(s), ' '.join(map(str, s)))
	print(len(a), ' '.join(map(str, a)))
main()


n = int(input())
a = list(map(int, input().split()))
(n, p, z) = ([], [], [])
(flagn, flagp) = (0, 0)
cpos = 0
for i in a:
	if i > 0:
		cpos += 1
if cpos:
	for i in a:
		if i < 0:
			if not flagn:
				n.append(i)
				flagn += 1
			else:
				z.append(i)
		elif i > 0:
			if not flagp:
				p.append(i)
				flagp += 1
			else:
				z.append(i)
		else:
			z.append(i)
else:
	for i in a:
		if i < 0:
			if not flagn:
				n.append(i)
				flagn += 1
			elif len(p) < 2:
				p.append(i)
			else:
				z.append(i)
		else:
			z.append(i)
print(len(n), *n)
print(len(p), *p)
print(len(z), *z)


n = int(input())
a = list(map(int, input().split()))
n1 = []
n2 = []
n3 = []
totalNegative = 0

def countNegative(x):
	count = 0
	for i in range(len(x)):
		if x[i] < 0:
			count += 1
	return count
totalNegative = countNegative(a)

def findProduct(x):
	product = 1
	for i in range(len(x)):
		product *= x[i]
	return product

def printResult(x):
	print(len(x), end=' ')
	for i in range(len(x)):
		print(x[i], end=' ')
	print()
for i in range(len(a)):
	if a[i] == 0:
		n3.append(a[i])
	elif totalNegative == 1:
		if len(n1) == 0 and a[i] < 0:
			n1.append(a[i])
		else:
			n2.append(a[i])
	elif totalNegative == 2:
		if len(n1) == 0 and a[i] < 0:
			n1.append(a[i])
		elif a[i] > 0:
			n2.append(a[i])
		else:
			n3.append(a[i])
	elif len(n1) == 0 and a[i] < 0:
		n1.append(a[i])
	elif len(n2) < 2 and a[i] < 0:
		n2.append(a[i])
	else:
		n3.append(a[i])
printResult(n1)
printResult(n2)
printResult(n3)


n = int(input())
b = list(map(int, input().split()))
neg = 0
pos = 0
neg1 = 0
neg2 = 0
for i in range(n):
	if b[i] < 0 and neg == 0:
		neg = b[i]
	elif pos == 0 and b[i] > 0:
		pos = b[i]
	elif b[i] < 0 and neg1 == 0:
		neg1 = b[i]
	elif b[i] < 0 and neg2 == 0:
		neg2 = b[i]
print(1, neg)
if pos != 0:
	print(1, pos)
	print(n - 2, ' ', end='')
	for i in range(n):
		if b[i] != neg and b[i] != pos:
			print(b[i], ' ', end='')
	print('')
else:
	print(2, neg1, neg2)
	print(n - 3, ' ', end='')
	for i in range(n):
		if b[i] != neg and b[i] != neg1 and (b[i] != neg2):
			print(b[i], ' ', end='')
	print('')


n = int(input())
numbers = list(map(int, input().strip().split()))
set1 = []
set2 = []
set3 = []
numbers.sort()
set1.append(numbers[0])
numbers.pop(0)
if numbers[n - 2] > 0:
	set2.append(numbers[n - 2])
	numbers.pop(n - 2)
else:
	set2.append(numbers[0])
	set2.append(numbers[1])
	numbers.pop(0)
	numbers.pop(0)
for i in range(len(numbers)):
	set3.append(numbers[i])
print(len(set1), end=' ')
for i in range(len(set1)):
	print(set1[i], end=' ')
print()
print(len(set2), end=' ')
for i in range(len(set2)):
	print(set2[i], end=' ')
print()
print(len(set3), end=' ')
for i in range(len(set3)):
	print(set3[i], end=' ')
print()


n = int(input())
s = list(map(int, input().split()))
(a, b, c) = ([], [], [])
for r in s:
	if r < 0:
		a.append(r)
	if r > 0:
		b.append(r)
	if r == 0:
		c.append(r)
(s1, s2) = ([], [])
if len(a) % 2 == 0:
	c.append(a[len(a) - 1])
	a.pop()
if len(a) % 2 == 1 and len(b) != 0:
	s1.append(len(a))
	for i in a:
		s1.append(i)
	s2.append(len(b))
	for j in b:
		s2.append(j)
elif len(a) % 2 == 1 and len(b) == 0:
	s1.append(len(a) - 2)
	for i in range(len(a) - 2):
		s1.append(a[i])
	s2.append(2)
	s2.append(a[len(a) - 1])
	s2.append(a[len(a) - 2])
for e in s1:
	print(e, end=' ')
print()
for w in s2:
	print(w, end=' ')
print()
c.insert(0, len(c))
for p in c:
	print(p, end=' ')


input()
items = sorted(list(map(int, input().split())))
s1 = {items[0]}
s3 = {0}
if len([x for x in items[1:] if x < 0]) % 2:
	s3.add(items[1])
	items = items[2:]
else:
	items = items[1:]
s2 = {x for x in items if x != 0}
print(len(s1), ' '.join((str(x) for x in s1)))
print(len(s2), ' '.join((str(x) for x in s2)))
print(len(s3), ' '.join((str(x) for x in s3)))


input()
a = list(map(int, input().split()))
b = []
c = 0
a.sort()
for i in a:
	if i == 0:
		b.append(0)
		a.remove(0)
	if i < 0:
		c += 1
print('1' + ' ' + str(a[0]))
if c % 2:
	print(str(len(a[1:])) + ' ', end='')
	for i in a[1:]:
		print(i, end=' ')
else:
	print(str(len(a[2:])) + ' ', end='')
	for i in a[2:]:
		print(i, end=' ')
print()
if c % 2:
	print(str(len(b)) + ' ', end='')
	for i in b:
		print(0, end=' ')
else:
	print(str(len(b) + 1) + ' ', end='')
	for i in b:
		print(0, end=' ')
	print(a[1])


import sys
my_file = sys.stdin
n = int(my_file.readline().strip())
a = [int(i) for i in my_file.readline().strip().split()]
negatives = []
positives = []
zeros = []
neg = 0
pos = 0
zer = 0
for i in a:
	if i > 0:
		pos += 1
	elif i < 0:
		neg += 1
	else:
		zer += 1
if pos == 0:
	for i in range(n):
		try:
			if a[i] < 0 and len(positives) < 2:
				positives.append(a[i])
				del a[i]
		except:
			pass
	for i in range(len(a)):
		try:
			if a[i] < 0 and len(negatives) < 1:
				negatives.append(a[i])
				del a[i]
				break
		except:
			pass
	zeros = a
else:
	for i in range(n):
		try:
			if a[i] > 0 and len(positives) < 1:
				positives.append(a[i])
				del a[i]
				break
		except:
			pass
	for i in range(len(a)):
		try:
			if a[i] < 0 and len(negatives) < 1:
				negatives.append(a[i])
				del a[i]
				break
		except:
			pass
	zeros = a
print(len(negatives), ' '.join(map(str, negatives)))
print(len(positives), ' '.join(map(str, positives)))
print(len(zeros), ' '.join(map(str, zeros)))


n = int(input())
all = list(map(int, input().split()))
pos = []
neg = []

def pprint(x):
	print(len(x), end=' ')
	for (i, j) in enumerate(x):
		if i != len(x) - 1:
			print(j, end=' ')
		else:
			print(j)
for i in all[:]:
	if i < 0:
		neg.append(i)
		all.remove(i)
		break
for i in all[:]:
	if i > 0:
		pos.append(i)
		all.remove(i)
		break
if len(pos) == 0:
	c = 0
	for i in all[:]:
		if i < 0:
			pos.append(i)
			all.remove(i)
			c += 1
			if c == 2:
				break
pprint(neg)
pprint(pos)
pprint(all)


i = int(input())
l = list(map(int, input().split()))
g = l[:]
a = b = c = d = 0
for x in range(0, i):
	if l[x] < 0 and a == 0:
		a = l[x]
		g.pop(x - d)
		d += 1
	elif l[x] > 0 and b == 0:
		b = l[x]
		g.pop(x - d)
		d += 1
cc = g[:]
if a == 0:
	x = 0
	while True:
		if g[x] < 0:
			cc.remove(g[x])
			break
		x += 1
aa = []
t = 1
dd = cc[:]
if b == 0:
	x = 0
	c = 0
	while True:
		if cc[x] < 0:
			aa.append(cc[x])
			dd.remove(cc[x])
			c += 1
			if c == 2:
				break
		x += 1
	t = 2
	b = str(aa[0]) + ' ' + str(aa[1])
print(1, a)
print(t, b)
print(len(dd), ' '.join([str(elem) for elem in dd]))


n = int(input().strip())
arr = list(map(int, input().strip().split()))
(negs, pos) = ([], [])
zeros = 0
for i in arr:
	if i < 0:
		negs.append(i)
	elif i > 0:
		pos.append(i)
	else:
		zeros += 1
(first, second, third) = (negs, pos, [0] * zeros)
if len(first) % 2 == 0:
	third.append(first.pop())
if len(pos) == 0:
	second.append(first.pop())
	second.append(first.pop())
print(len(first), *first)
print(len(second), *second)
print(len(third), *third)


n = int(input())
a = [int(i) for i in input().split(' ')]
num = [[], [], []]
for i in a:
	if i < 0:
		num[0].append(i)
	elif i == 0:
		num[1].append(i)
	else:
		num[2].append(i)
if len(num[2]) == 0:
	cnt = 0
	while cnt < 2:
		q = num[0].pop(0)
		num[2].append(q)
		cnt += 1
if len(num[0]) % 2 == 0:
	q = num[0].pop(0)
	num[1].append(q)
for i in [0, 2, 1]:
	num[i] = [str(items) for items in num[i]]
	print(str(len(num[i])) + ' ' + ' '.join(num[i]))


n = int(input())
arr = sorted(list(map(int, input().split())))
if arr[n - 1] > 0:
	print('1 ' + str(arr[0]))
	print('1 ' + str(arr[n - 1]))
	res = ''
	for i in arr[1:n - 1]:
		res += ' ' + str(i)
	print(str(n - 2) + res)
else:
	print('1 ' + str(arr[0]))
	print('2 ' + str(arr[1]) + ' ' + str(arr[2]))
	res = ''
	for i in arr[3:]:
		res += ' ' + str(i)
	print(str(n - 3) + res)


n = int(input())
arr = list(map(int, input().split()))
zero = []
positive = []
negative = []
for i in arr:
	if i > 0:
		positive.append(i)
	elif i < 0:
		negative.append(i)
	else:
		zero.append(i)
negativesize = len(negative)
positivesize = len(positive)
if negativesize % 2 == 0:
	zero.append(negative[negativesize - 1])
	negative.pop(negativesize - 1)
	negativesize -= 1
count = 0
if positivesize == 0:
	while count < 2:
		positive.append(negative[negativesize - 1])
		negative.pop(negativesize - 1)
		negativesize -= 1
		count += 1
		positivesize += 1
print(negativesize, end=' ')
for i in negative:
	print(i, end=' ')
print()
print(len(positive), end=' ')
for i in positive:
	print(i, end=' ')
print()
print(len(zero), end=' ')
for i in zero:
	print(i, end=' ')


n = int(input())
l = list(map(int, input().strip().split()))
f = []
s = []
t = []
flag3 = 0
temp = []
for i in range(0, n):
	if l[i] < 0 and flag3 == 0:
		f.append(l[i])
		flag3 = 1
	elif l[i] == 0:
		s.append(l[i])
	elif flag3 == 1 and l[i] < 0:
		temp.append(l[i])
		if len(temp) == 2:
			t.extend([k for k in temp])
			temp = []
	elif l[i] > 0:
		t.append(l[i])
if len(temp) != 0:
	s.extend(temp)
print(len(f), *f)
print(len(t), *t)
print(len(s), *s)


n = int(input())
a = list(map(int, input().split()))
c = 0
d = 0
l1 = []
l2 = []
l3 = []
for i in a:
	if i < 0:
		c += 1
		l1.append(i)
	if i == 0:
		l2.append(i)
	if i > 0:
		l3.append(i)
if c % 2 == 0:
	l2.append(l1[0])
	l1 = l1[1:]
if l3 == []:
	l3.append(l1[0])
	l3.append(l1[1])
	l1 = l1[2:]
print(len(l1), end=' ')
print(*l1)
print(len(l3), end=' ')
print(*l3)
print(len(l2), end=' ')
print(*l2)


__copyright__ = ''
__author__ = 'Son-Huy TRAN'
__email__ = 'sonhuytran@gmail.com'
__doc__ = ''
__version__ = '1.0'

def print_list(numbers: list) -> None:
	temp = [str(number) for number in numbers]
	print(len(temp), end=' ')
	print(' '.join(temp))

def main() -> int:
	n = int(input())
	numbers = [int(word) for word in input().split()]
	negatives = [i for i in numbers if i < 0]
	positives = [i for i in numbers if i > 0]
	zero = [0]
	group1 = [negatives[0]]
	group2 = negatives[1:] + positives
	if len(negatives) % 2 == 0:
		zero.append(group2[0])
		group2 = group2[1:]
	print_list(group1)
	print_list(group2)
	print_list(zero)
	return 0
exit(main())


n = int(input())
l = list(map(int, input().split()))
l1 = []
l2 = []
l3 = []
for i in l:
	if i < 0:
		l1.append(i)
	elif i > 0:
		l2.append(i)
	else:
		l3.append(i)
if len(l2) == 0:
	l2.append(l1.pop())
	l2.append(l1.pop())
if len(l1) % 2 == 0:
	l3.append(l1.pop())
print(len(l1), end=' ')
print(' '.join(list(map(str, l1))))
print(len(l2), end=' ')
print(' '.join(list(map(str, l2))))
print(len(l3), end=' ')
print(' '.join(list(map(str, l3))))


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')
readint = lambda : int(sys.stdin.readline().rstrip('\r\n'))
readints = lambda : map(int, sys.stdin.readline().rstrip('\r\n').split())
readstr = lambda : sys.stdin.readline().rstrip('\r\n')
readstrs = lambda : map(str, sys.stdin.readline().rstrip('\r\n').split())
readarri = lambda : [int(_) for _ in sys.stdin.readline().rstrip('\r\n').split()]
readarrs = lambda : [str(_) for _ in sys.stdin.readline().rstrip('\r\n').split()]

def solve():
	(n, arr) = (readint(), readarri())
	arr.sort()
	print(1, arr[0])
	arr.remove(arr[0])
	arr.remove(0)
	negatives = sum((arr[i] < 0 for i in range(len(arr))))
	if negatives % 2 == 0:
		print(len(arr), *arr)
		print(1, 0)
	else:
		print(len(arr) - 1, *arr[1:])
		print(2, 0, arr[0])

def main():
	t = 1
	for _ in range(t):
		solve()
main()


n = int(input())
a = list(map(int, input().split()))
(x, y, z) = ([], [], [])
(f1, f2, f3) = (0, 0, 0)
(ng, p, d) = (0, 0, 0)
for i in a:
	if i < 0:
		ng += 1
	elif i > 0:
		p += 1
	else:
		d += 1
for i in a:
	if i < 0 and f1 == 0:
		x.append(i)
		f1 = 1
	elif i > 0:
		y.append(i)
	else:
		z.append(i)
if not y:
	z.sort()
	y.append(z[0])
	y.append(z[1])
	del z[0]
	del z[0]
print(len(x), *x)
print(len(y), *y)
print(len(z), *z)


n = int(input())
a = list(map(int, input().split()))
n1 = []
n2 = []
n3 = []
count1 = 0
count2 = 0
count3 = 0
pos = 0
for i in a:
	if i < 0:
		n1.append(i)
		count1 += 1
	elif i > 0:
		n2.append(i)
		count2 += 1
	else:
		n3.append(i)
		count3 += 1
if count2 == 0:
	n2.append(n1[len(n1) - 1])
	n1.pop()
	n2.append(n1[len(n1) - 1])
	n1.pop()
	count1 -= 2
	count2 += 2
if count1 % 2 == 0:
	n3.append(n1[len(n1) - 1])
	n1.pop()
	count1 -= 1
	count3 += 1
print(count1, ' '.join(map(str, n1)))
print(count2, ' '.join(map(str, n2)))
print(count3, ' '.join(map(str, n3)))


n = int(input())
arr = list(map(int, input().split()))
arrp = []
arrn = []
arrz = []
for i in range(n):
	if arr[i] > 0:
		arrp.append(arr[i])
	elif arr[i] < 0:
		arrn.append(arr[i])
	else:
		arrz.append(arr[i])
if len(arrp) == 0:
	arrp.append(arrn[0])
	arrp.append(arrn[1])
	arrn.pop(0)
	arrn.pop(0)
if len(arrn) % 2 == 0:
	arrz.append(arrn[0])
	arrn.pop(0)
print(len(arrn), end=' ')
for i in range(len(arrn)):
	print(arrn[i], end=' ')
print('')
print(len(arrp), end=' ')
for i in range(len(arrp)):
	print(arrp[i], end=' ')
print('')
print(len(arrz), end=' ')
for i in range(len(arrz)):
	print(arrz[i], end=' ')


n = int(input())
l = list(map(int, input().split()))
pos = []
neg = []
zero = []
for i in l:
	if i > 0:
		pos.append(i)
	elif i < 0:
		neg.append(i)
	else:
		zero.append(i)
if not len(neg) & 1:
	zero.append(neg[0])
	neg.pop(0)
if not len(pos):
	pos.append(neg[0])
	pos.append(neg[1])
	neg.pop(0)
	neg.pop(0)
print(len(neg), *neg)
print(len(pos), *pos)
print(len(zero), *zero)


n = int(input())
zero = []
pos = []
neg = []
a = list(map(int, input().split()))
for i in a:
	if i > 0:
		pos.append(i)
	elif i < 0:
		neg.append(i)
	else:
		zero.append(i)
if len(pos) == 0:
	pos.extend([neg[0], neg[1]])
	del neg[0]
	del neg[0]
if len(neg) % 2 == 0:
	zero.append(neg[0])
	del neg[0]
print(len(neg), *neg)
print(len(pos), *pos)
print(len(zero), *zero)


n = int(input())
l = [int(x) for x in input().split()]
c = 0
for i in range(n):
	if l[i] >= 1:
		c = l[i]
l.sort()
print(1, l[0])
if c == 0:
	print(2, l[1], l[2])
	print(n - 3, end=' ')
	for i in range(3, n):
		print(l[i], end=' ')
else:
	print(1, c)
	print(n - 2, end=' ')
	for i in range(1, n):
		if l[i] != c:
			print(l[i], end=' ')


n = int(input())
a = list(map(int, input().split()))
b = [i for i in a if i > 0]
c = [i for i in a if i < 0]
d = [i for i in a if i == 0]
if len(c) % 2 == 1:
	n1 = [c[0]]
	n2 = b + c[1:]
	n3 = d
else:
	n1 = [c[0]]
	n2 = b + c[1:len(c) - 1]
	n3 = [c[len(c) - 1]] + d
print(len(n1), end=' ')
print(*n1, end=' ')
print('')
print(len(n2), end=' ')
print(*n2, end=' ')
print('')
print(len(n3), end=' ')
print(*n3, end=' ')
print('')


n = int(input())
l = input().split()
(pos, z) = ([], [])
flag = 1
f = 1
for i in range(n):
	l[i] = int(l[i])
	if l[i] < 0 and flag:
		neg = l[i]
		flag = 0
	elif l[i] > 0 and f:
		pos.append(l[i])
		x = 1
		f = 0
	else:
		z.append(l[i])
if f:
	x = 2
	i = 0
	while i < len(z):
		if z[i] < 0 and len(pos) < 2:
			pos.append(z[i])
			z.pop(i)
			i -= 1
		i += 1
print(1, neg)
if x == 1:
	print(1, pos[0])
else:
	print(x, '', end='')
	for i in range(x):
		print(pos[i], '', end='')
	print()
print(n - x - 1, '', end='')
for i in range(n - x - 1):
	print(z[i], '', end='')


n = int(input())
a = list(map(int, input().split()))
negative = []
zeros = []
positive = []
for x in a:
	if x < 0:
		negative.append(x)
	elif x == 0:
		zeros.append(x)
	else:
		positive.append(x)
if len(positive) == 0:
	positive.append(negative[-1])
	positive.append(negative[-2])
	negative.pop()
	negative.pop()
if len(negative) % 2 == 0:
	zeros.append(negative[-1])
	negative.pop()

def printPattern(a):
	print(len(a), end=' ')
	for x in a:
		print(x, end=' ')
printPattern(negative)
print()
printPattern(positive)
print()
printPattern(zeros)


n = int(input())
k = list(map(int, input().split()))
set1 = []
set2 = []
set3 = []
k.sort()
count = 0
for i in k:
	if i < 0:
		count += 1
temp = count
if count % 2 == 0:
	for i in k:
		if temp // 2 % 2 == 0:
			if i < 0 and count == temp:
				set1.append(i)
				count -= 1
			elif i > 0 or (i < 0 and count != 1):
				set2.append(i)
				count -= 1
			else:
				set3.append(i)
		elif i < 0 and count > temp // 2:
			set1.append(i)
			count -= 1
		elif i > 0 or (i < 0 and count != 1):
			set2.append(i)
			count -= 1
		else:
			set3.append(i)
else:
	for i in k:
		if i < 0 and count != 2:
			set1.append(i)
			count -= 1
		elif i > 0 or (i < 0 and count == 2):
			set2.append(i)
		else:
			set3.append(i)
k1 = list(map(str, set1))
k2 = list(map(str, set2))
k3 = list(map(str, set3))
print(len(k1), ' '.join(k1))
print(len(k2), ' '.join(k2))
print(len(k3), ' '.join(k3))


x = int(input())
l = list(map(int, input().split(' ')))
a = [i for i in l if i == 0]
b = [i for i in l if i < 0]
c = [i for i in l if i > 0]
if len(c) == 0:
	c.append(b[0])
	c.append(b[1])
	b = b[2:]
if len(b) % 2 == 0:
	a.append(b[0])
	b = b[1:]
a = [str(x) for x in a]
b = [str(x) for x in b]
c = [str(x) for x in c]
print(len(b), ' '.join(b))
print(len(c), ' '.join(c))
print(len(a), ' '.join(a))


import math
import sys
import collections

def getdict(n):
	d = {}
	if type(n) is list:
		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 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)
n = ii()
d = li()
a = [[] for i in range(3)]
pos = 0
for i in d:
	if i > 0:
		pos += 1
for i in d:
	if i < 0 and len(a[0]) == 0:
		a[0].append(i)
	elif i > 0 or (i < 0 and pos == 0 and (len(a[1]) < 2)):
		a[1].append(i)
	else:
		a[2].append(i)
for i in range(3):
	print(len(a[i]), ' '.join(map(str, a[i])))


n = int(input())
lst = [int(i) for i in input().split()]
a = [i for i in lst if i < 0]
b = [i for i in lst if i > 0]
c = [i for i in lst if i == 0]
if len(b) == 0:
	(b, a) = (a[:2], a[2:])
c += a[1:]
a = a[0]
print(1, a)
print(len(b), ' '.join((str(i) for i in b)))
print(len(c), ' '.join((str(i) for i in c)))


n = int(input())
k = input().split()
x = []
(l, nn, pn, p, z) = (0, 0, 0, 0, 1)
for i in k:
	if int(i) < 0 and l == 0 and (x.count(i) == 0):
		j = int(i)
		print('1 {0}'.format(j))
		x.append(i)
		l = 1
	elif int(i) > 0:
		pn += 1
	elif int(i) < 0:
		nn += 1
ans2 = []
if pn >= 1:
	for i in k:
		if int(i) > 0 and x.count(i) == 0:
			ans2.append(1)
			ans2.append(int(i))
			x.append(i)
			z += 1
			break
elif nn >= 2:
	ans2.append(2)
	for i in k:
		if int(i) < 0 and p != 2 and (x.count(i) == 0):
			ans2.append(int(i))
			p += 1
			z += 1
			x.append(i)
for i in ans2:
	print(i, end=' ')
print(end='\n')
print(n - z, end=' ')
for i in k:
	if x.count(i) == 0:
		print(i, end=' ')


n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
neg = list(filter(lambda x: x < 0, a))
pos = list(filter(lambda x: x > 0, a))
if len(pos) > 0:
	if len(neg) % 2 == 0:
		print(len(neg) - 1, end=' ')
		for i in range(len(neg) - 1):
			print(neg[i], end=' ')
		print()
		print(len(pos), end=' ')
		for i in pos:
			print(i, end=' ')
		print()
		print(2, end=' ')
		print(neg[len(neg) - 1], 0)
	else:
		print(len(neg), end=' ')
		for i in range(len(neg)):
			print(neg[i], end=' ')
		print()
		print(len(pos), end=' ')
		for i in pos:
			print(i, end=' ')
		print()
		print(1, end=' ')
		print(0)
elif len(neg) % 2 == 0:
	print(len(neg) - 3, end=' ')
	for i in range(len(neg) - 3):
		print(neg[i], end=' ')
	print()
	print(2, neg[len(neg) - 3], neg[len(neg) - 2])
	print()
	print(2, end=' ')
	print(neg[len(neg) - 1], 0)
else:
	print(len(neg) - 2, end=' ')
	for i in range(len(neg) - 2):
		print(neg[i], end=' ')
	print()
	print(2, neg[len(neg) - 2], neg[len(neg) - 1])
	print()
	print(1, end=' ')
	print(0)


n = int(input())
l = list(map(int, input().split()))
l.remove(0)
(a2, a3) = ([], [])
a3.append(0)
n = 0
no = []
p = 0
po = []
for i in l:
	if i < 0:
		n += 1
		no.append(i)
	else:
		p += 1
		po.append(i)
if n & 1 == 0:
	l.remove(no[0])
	a3.append(no[0])
	no.remove(no[0])
if p == 0:
	a2.append(no[0])
	a2.append(no[1])
	l.remove(no[0])
	l.remove(no[1])
else:
	a2.append(po[0])
	l.remove(po[0])
l1 = len(l)
l2 = len(a2)
l3 = len(a3)
print(l1, end=' ')
for i in l:
	print(i, end=' ')
print('\n' + str(l2), end=' ')
for i in a2:
	print(i, end=' ')
print('\n' + str(l3), end=' ')
for i in a3:
	print(i, end=' ')
print()


def arr_inp():
	return [int(x) for x in input().split()]

def print_arr(arr):
	print(*arr, sep=' ')
(n, a) = (int(input()), arr_inp())
a.sort()
print(1, a[0])
if a[1] < 0 and a[2] < 0:
	print(2, a[1], a[2])
	print(n - 3, end=' ')
	print_arr(a[3:])
else:
	print(1, a[n - 1])
	print(n - 2, end=' ')
	print_arr(a[1:n - 1])


n = int(input())
numList = list(map(int, input().split()))[:n]
lst_1 = []
lst_2 = []
lst_3 = []
for i in numList:
	if i < 0:
		lst_1.append(i)
	elif i > 0:
		lst_2.append(i)
	elif i == 0:
		lst_3.append(i)
if len(lst_2) == 0:
	count = 0
	for i in range(1, len(lst_1)):
		a = len(lst_1) - i
		lst_2.append(lst_1[a])
		count += 1
		if count == 2:
			break
	lst_1 = lst_1[:len(lst_1) - 2]
if len(lst_1) % 2 == 0:
	lst_3.append(lst_1[len(lst_1) - 1])
	lst_1 = lst_1[:len(lst_1) - 1]

def prin(lst):
	res = ''
	for i in lst:
		res = res + str(i) + ' '
	return res
print(len(lst_1), prin(lst_1))
print(len(lst_2), prin(lst_2))
print(len(lst_3), prin(lst_3))


n = int(input())
ll = [[], [], []]
for a in (int(x) for x in input().split()):
	if a == 0:
		ll[2].append(a)
	elif a < 0:
		if not ll[0]:
			ll[0].append(a)
		else:
			ll[2].append(a)
	else:
		ll[1].append(a)
if not ll[1]:
	ll[2].sort()
	ll[1] = ll[2][:2]
	ll[2] = ll[2][2:]
for l in ll:
	print(len(l), end=' ')
	print(' '.join(map(str, l)))


n = int(input())
r = lambda : list(map(int, input().split()))
arr = r()
neg = [i for i in arr if i < 0]
pos = [i for i in arr if i > 0]
zero = [0]
if len(neg) % 2 == 0:
	pos.extend(neg[1:-1])
	zero.append(neg[-1])
	neg = neg[:1]
elif len(pos) == 0:
	pos.extend(neg[-2:])
	neg = neg[:-2]
print(len(neg), *neg)
print(len(pos), *pos)
print(len(zero), *zero)


x = int(input())
y = list(map(int, input().split()))
(a, b, c) = ([], [], [])
for i in y:
	if i < 0:
		a.append(i)
	elif i > 0:
		b.append(i)
	else:
		c.append(i)
if len(b) == 0:
	b.append(a[0])
	b.append(a[1])
	a.remove(a[0])
	a.remove(a[0])
if len(a) % 2 == 0:
	c.append(a[0])
	a.remove(a[0])
print(len(a), *a)
print(len(b), *b)
print(len(c), *c)


n = int(input())
ls = list(map(int, input().split()))
(xs, ys, zs) = ([], [], [])
for a in ls:
	if a < 0:
		if len(xs) == 0:
			xs.append(a)
		elif len(ys) == 0 or (len(ys) == 1 and ys[0] < 0):
			ys.append(a)
		else:
			zs.append(a)
	elif 0 < a:
		if len(ys) == 0:
			ys.append(a)
		elif len(ys) == 1 and ys[0] < 0:
			zs.append(ys[0])
			ys[0] = a
		else:
			zs.append(a)
	else:
		zs.append(a)
print(len(xs), ' '.join(map(str, xs)))
print(len(ys), ' '.join(map(str, ys)))
print(len(zs), ' '.join(map(str, zs)))


n = int(input())
vals = [*map(int, input().split())]
neg = [i for i in vals if i < 0]
pos = [i for i in vals if i > 0]
zeros = vals.count(0)
a = 0
print(1, neg[0])
neg = neg[1:]
if len(neg) & 1 == 0:
	print(len(pos) + len(neg), *neg, *pos)
else:
	a = neg[0]
	neg = neg[1:]
	print(len(pos) + len(neg), *neg, *pos)
if a:
	print(str(zeros + 1) + ' 0' * zeros + ' ', a)
else:
	print(str(zeros) + ' 0' * zeros)


n = int(input())
x = list(map(int, input().split()))
neg = []
pos = []
zer = []
for k in x:
	if k == 0:
		zer.append(0)
	elif k > 0:
		pos.append(k)
	else:
		neg.append(k)
if len(neg) % 2 == 0:
	zer.append(neg[0])
	neg = neg[1:]
if len(pos) == 0:
	pos = [neg[0], neg[1]]
	neg = neg[2:]
pos = list(map(str, pos))
neg = list(map(str, neg))
zer = list(map(str, zer))
print(len(neg), ' '.join(neg))
print(len(pos), ' '.join(pos))
print(len(zer), ' '.join(zer))


n = int(input())
a = [int(i) for i in input().split(' ')]
d = {'negative': {'count': 0, 'items': []}, 'positive': {'count': 0, 'items': []}, 'zero': {'count': 0, 'items': []}}
for i in a:
	if i < 0:
		d['negative']['count'] += 1
		d['negative']['items'].append(i)
	elif i > 0:
		d['positive']['count'] += 1
		d['positive']['items'].append(i)
	else:
		d['zero']['count'] += 1
		d['zero']['items'].append(i)
if d['positive']['count'] == 0:
	d['positive']['items'].append(d['negative']['items'].pop())
	d['positive']['items'].append(d['negative']['items'].pop())
if len(d['negative']['items']) % 2 == 0:
	d['zero']['items'].append(d['negative']['items'].pop())
output = '{} '.format(len(d['negative']['items']))
for i in d['negative']['items']:
	output += '{} '.format(i)
output.strip()
print(output)
output = '{} '.format(len(d['positive']['items']))
for i in d['positive']['items']:
	output += '{} '.format(i)
output.strip()
print(output)
output = '{} '.format(len(d['zero']['items']))
for i in d['zero']['items']:
	output += '{} '.format(i)
output.strip()
print(output)


n = int(input())
l = list(map(int, input().split()))
a = 0
b = 0
neg = []
z = []
pos = []
for i in l:
	if i > 0:
		b = b + 1
		pos.append(i)
	elif i < 0:
		a = a + 1
		neg.append(i)
	else:
		z.append(i)
if a % 2 == 0:
	z.append(neg.pop())
if b == 0 and a > 1:
	pos.append(neg.pop())
	pos.append(neg.pop())
print(len(neg), *neg)
print(len(pos), *pos)
print(len(z), *z)


n = int(input())
a = [int(i) for i in input().split()]
neg = list(filter(lambda x: x < 0, a))
pos = list(filter(lambda x: x > 0, a))
zero = list(filter(lambda x: x == 0, a))
if len(pos) == 0:
	pos.append(neg[0])
	neg.pop(0)
	pos.append(neg[0])
	neg.pop(0)
if len(neg) % 2 == 0:
	zero.append(neg[0])
	neg.pop(0)
print(len(neg), end=' ')
for i in neg:
	print(i, end=' ')
print()
print(len(pos), end=' ')
for i in pos:
	print(i, end=' ')
print()
print(len(zero), end=' ')
for i in zero:
	print(i, end=' ')
print()


import sys
from collections import defaultdict as dd
pl = 1
from math import *
import copy
if pl:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

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

def fi():
	return int(input())

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())
d = []
from bisect import *
from itertools import permutations
from collections import deque

def siv(n):
	prime = [True for i in range(n + 1)]
	p = 2
	if 1:
		while p * p <= n:
			if prime[p] == True:
				for i in range(p * p, n + 1, p):
					prime[i] = False
			p += 1
		for p in range(2, n + 1):
			if prime[p]:
				d.append(p)
n = fi()
a = li()
ne = []
p = []
z = []
for i in range(n):
	if a[i] < 0:
		if len(ne) == 0:
			ne.append(a[i])
		else:
			z.append(a[i])
	elif a[i] > 0:
		p.append(a[i])
	else:
		z.append(a[i])
if len(p) == 0:
	z.sort()
	p.append(z[0])
	p.append(z[1])
	z = z[2:]
print(len(ne), *ne)
print(len(p), *p)
print(len(z), *z)


n = int(input())
arr = list(map(int, input().split()))
negative_cnt = 0
arr1 = []
arr2 = []
arr3 = []
for i in range(0, n):
	if arr[i] < 0:
		arr1.append(arr[i])
		negative_cnt += 1
	elif arr[i] > 0:
		arr2.append(arr[i])
	elif arr[i] == 0:
		arr3.append(arr[i])
if len(arr2) == 0:
	for k in range(2):
		arr2.append(arr1.pop())
if negative_cnt % 2 == 0:
	arr3.append(arr1.pop())
print(len(arr1), *arr1, sep=' ')
print(len(arr2), *arr2, sep=' ')
print(len(arr3), *arr3, sep=' ')


z = input()
x = sorted(list(map(int, input().split())))
print(1, x[0])
x.remove(x[0])
if x[0] * x[1] > 0:
	print(2, x[0], x[1])
	x.remove(x[0])
	x.remove(x[0])
else:
	print(1, x[-1])
	x.remove(x[-1])
print(len(x), *x)


n = int(input())
l = list(map(int, input().split()))
l1 = []
l2 = []
l3 = []
c = 0
c2 = 0
c3 = 0
for i in l:
	if i < 0:
		l1.append(i)
		c += 1
	if i == 0:
		l3.append(i)
		c3 += 1
	if i > 0:
		l2.append(i)
		c2 += 1
if c2 == 0:
	l2.append(l1[0])
	l2.append(l1[1])
	l1.remove(l1[0])
	l1.remove(l1[0])
	c -= 2
	c2 += 2
if c % 2 == 0:
	l3.append(l1[0])
	l1.remove(l1[0])
	c3 += 1
	c -= 1
print(c, end=' ')
for i in l1:
	print(i, end=' ')
print()
print(c2, end=' ')
for i in l2:
	print(i, end=' ')
print()
print(c3, end=' ')
for i in l3:
	print(i, end=' ')
print()


def DivideArray(Array):
	NegativeArray = []
	PositiveArray = []
	ZeroArray = []
	for i in range(0, len(Array)):
		if Array[i] < 0:
			NegativeArray.append(Array[i])
		if Array[i] > 0:
			PositiveArray.append(Array[i])
		if Array[i] == 0:
			ZeroArray.append(Array[i])
	if len(PositiveArray) == 0:
		PositiveArray.append(NegativeArray[-1])
		PositiveArray.append(NegativeArray[-2])
		NegativeArray.pop()
		NegativeArray.pop()
	if len(NegativeArray) % 2 == 0:
		ZeroArray.append(NegativeArray[-1])
		NegativeArray.pop()
	return (NegativeArray, PositiveArray, ZeroArray)

def display(arr):
	print(len(arr), end=' ')
	for i in range(len(arr)):
		print(arr[i], end=' ')
	print(' ')
	return 0
Size = int(input())
Array = list(map(int, input().split()))
(Neg, Pos, Zero) = DivideArray(Array)
display(Neg)
display(Pos)
display(Zero)
DivideArray(Array)


n = int(input())
l = [int(i) for i in input().split()]
a = []
b = []
c = []
for i in range(n):
	if l[i] < 0:
		a.append(l[i])
	if l[i] > 0:
		b.append(l[i])
	if l[i] == 0:
		c.append(l[i])
if b == []:
	b = a[:2]
	a = a[2:]
if len(a) % 2 == 0:
	c.append(a[0])
	a = a[1:]
print(len(a), *a)
print(len(b), *b)
print(len(c), *c)


n = int(input())
a = []
b = []
c = []
for i in input().split():
	i = int(i)
	if i < 0:
		a.append(i)
	elif i == 0:
		b.append(i)
	else:
		c.append(i)
if len(c) == 0:
	c.append(a.pop())
	c.append(a.pop())
if len(a) % 2 == 0:
	b.append(a.pop())
print(len(a), ' '.join([str(i) for i in a]))
print(len(c), ' '.join([str(i) for i in c]))
print(len(b), ' '.join([str(i) for i in b]))


n = int(input())
p = list(map(int, input().split()))
nam = []
jil = []
for item in p:
	if item < 0:
		nam.append(item)
if len(nam) % 2 != 0:
	print(1, nam[0])
	p.remove(nam[0])
else:
	print(1, nam[0])
	p.remove(nam[0])
	jil.append(nam[1])
	p.remove(nam[1])
pop = p.count(0)
for x in range(pop):
	jil.append(0)
	p.remove(0)
jil.insert(0, len(jil))
print(len(p), *p)
print(*jil)


n = int(input())
a = list(map(int, input().split()))
(lz, mz, z, temp) = ([0], [0], [0], [])
for i in a:
	if lz[0] == 0 and i < 0:
		lz[0] = 1
		lz.append(i)
	elif i > 0 and mz[0] == 0:
		mz[0] = 1
		mz.append(i)
	elif i < 0 and len(temp) < 2:
		temp.append(i)
	else:
		z[0] += 1
		z.append(i)
if len(mz) == 1:
	mz[0] = 2
	mz += temp
else:
	z[0] += len(temp)
	z += temp
print('  '.join((str(x) for x in lz)))
print('  '.join((str(x) for x in mz)))
print('  '.join((str(x) for x in z)))


n = int(input())
numbers = list(map(int, input().split(' ')))
set1 = [i for i in numbers if i < 0]
set2 = [i for i in numbers if i > 0]
set3 = [i for i in numbers if i == 0]
numbers = sorted(numbers)
if len(set2) == 0:
	set2.append(set1.pop())
	set2.append(set1.pop())
if len(set1) % 2 == 0:
	set3.append(set1.pop())
print(len(set1), ' '.join(map(str, set1)))
print(len(set2), ' '.join(map(str, set2)))
print(len(set3), ' '.join(map(str, set3)))


n = int(input())
li = list(map(int, input().split()))
a = []
b = []
c = []
for i in li:
	if i < 0:
		a.append(i)
	elif i > 0:
		b.append(i)
	else:
		c.append(i)
if len(a) % 2 != 0 and len(b) == 0:
	b.append(a[0])
	b.append(a[1])
	a = a[2:]
elif len(b) == 0 and len(a) >= 3:
	b.append(a[0])
	b.append(a[1])
	a = a[2:]
	c.extend(a[1:])
	a = a[:1]
if len(a) % 2 == 0:
	c.extend(a[1:])
	a = a[:1]
print(len(a), *a)
print(len(b), *b)
print(len(c), *c)


N = int(input())
A = list(map(int, input().split()))
plus = []
minus = []
zero = []
for i in range(N):
	if A[i] > 0:
		plus.append(i)
	elif A[i] < 0:
		minus.append(i)
	else:
		zero.append(i)
first = []
second = []
last = []
if len(plus) == 0:
	for i in range(2):
		first.append(A[minus[i]])
	second.append(A[minus[2]])
	for j in range(3, len(minus)):
		last.append(A[minus[j]])
	for i in zero:
		last.append(A[i])
else:
	first.append(A[plus[0]])
	for i in range(1, len(plus)):
		last.append(A[plus[i]])
	second.append(A[minus[0]])
	for i in range(1, len(minus)):
		last.append(A[minus[i]])
	for i in zero:
		last.append(A[i])
print('{} {}'.format(len(second), ' '.join(map(str, second))))
print('{} {}'.format(len(first), ' '.join(map(str, first))))
print('{} {}'.format(len(last), ' '.join(map(str, last))))


n = input()
arr = list(map(int, input().split()))
(arr1, arr2, arr3) = ([], [], [])
for i in arr:
	if i == 0:
		arr3.append(i)
	elif i < 0:
		arr1.append(i)
	elif i > 0:
		arr2.append(i)
if len(arr1) % 2 == 0:
	arr3.append(arr1[0])
	arr1 = arr1[1:]
if len(arr2) == 0:
	for i in range(2):
		arr2.append(arr1[0])
		arr1 = arr1[1:]
print(len(arr1), ' '.join(map(str, arr1)))
print(len(arr2), ' '.join(map(str, arr2)))
print(len(arr3), ' '.join(map(str, arr3)))


n = int(input())
a = list(map(int, input().split()))
b = []
c = []
d = []
t = 0
q = 0
for i in a:
	if i > 0:
		b.append(i)
	elif i == 0:
		c.append(0)
	else:
		d.append(i)
		q += 1
if b == []:
	b = [d[0], d[1]]
	d.remove(d[0])
	d.remove(d[0])
if q % 2 == 0:
	c.append(d[0])
	d.remove(d[0])
print(len(d), end=' ')
for i in d:
	print(i, end=' ')
print()
print(len(b), end=' ')
for i in b:
	print(i, end=' ')
print()
print(len(c), end=' ')
for i in c:
	print(i, end=' ')


n = int(input())
a = list(map(int, input().split()))
a.sort()
print('1', a[0])
if a[-1] > 0:
	print('1', a[-1])
	print(n - 2, *a[1:-1])
else:
	print('2', a[1], a[2])
	print(n - 3, *a[3:])


(first, second, third) = ([], [], [])
n = int(input())
nums = list(map(int, input().split()))
for i in range(n):
	if nums[i] < 0:
		first.append(nums[i])
	elif nums[i] > 0:
		second.append(nums[i])
	else:
		third.append(nums[i])
if len(first) % 2 == 0:
	third.append(first[-1])
	first = first[:-1]
if len(second) == 0:
	second.append(first[-1])
	second.append(first[-2])
	first = first[:-2]
print(len(first), *first, sep=' ')
print(len(second), *second, sep=' ')
print(len(third), *third, sep=' ')


n = int(input())
a = list(map(int, input().split()))
a.sort()
s1 = []
s2 = []
s3 = []
count = int(0)
for i in range(n):
	if a[i] < 0:
		s1.append(a[i])
		count += 1
	elif a[i] == 0:
		s3.append(a[i])
	else:
		s2.append(a[i])
if count % 2 == 0:
	s3.append(s1[0])
	s1.remove(s1[0])
if len(s2) == 0:
	s2.append(s1[0])
	s2.append(s1[1])
	s1.remove(s2[0])
	s1.remove(s2[1])
print(len(s1), *s1)
print(len(s2), *s2)
print(len(s3), *s3)


x = int(input())
y = list(map(int, input().split()))
y.sort()
a = []
b = []
c = []
(n, p, z) = (0, 0, 0)
for i in y:
	if i < 0:
		n += 1
		a.append(i)
	elif i > 0:
		p += 1
		b.append(i)
	else:
		z += 1
		c.append(i)
print(1, a[0])
if p == 0:
	print(2, end=' ')
	for i in range(1, 3):
		print(a[i], end=' ')
	print()
	print(n - 3 + z, end=' ')
	for i in range(3, n):
		print(a[i])
	for i in range(z):
		print(0, end=' ')
else:
	print(len(b), end=' ')
	for i in b:
		print(i, end=' ')
	print()
	print(n - 1 + z, end=' ')
	for i in a[1:]:
		print(i, end=' ')
	for i in range(z):
		print(0, end=' ')


n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	for j in range(i + 1, n):
		if a[i] > a[j]:
			tem = a[i]
			a[i] = a[j]
			a[j] = tem
print('{0} {1}'.format(1, a[0]))
if a[-1] > 0:
	print('{0} {1}'.format(1, a[-1]))
	print(n - 2, end=' ')
	print(*a[1:-1])
else:
	print('{0} {1} {2}'.format(2, a[1], a[2]))
	print(n - 3, end=' ')
	print(*a[3:])


t = int(input())
l = list(map(int, input().split()))
nl = []
n = 0
pl = []
p = 0
zl = []
z = 0
for i in l:
	if i > 0:
		p += 1
		pl.append(i)
	elif i < 0:
		n += 1
		nl.append(i)
	else:
		z += 1
		zl.append(i)
if p == 0:
	(x, y) = (nl.pop(), nl.pop())
	pl.append(x)
	pl.append(y)
	p += 2
	n -= 2
if n % 2 == 0:
	x = nl.pop()
	zl.append(x)
	z += 1
	n -= 1
print(n, *nl)
print(p, *pl)
print(z, *zl)


z = int(input())
x = list(map(int, input().split()))
a = []
b = []
c = []
for o in range(z):
	if x[o] < 0:
		a.append(str(x[o]))
		x.pop(o)
		break
for i in range(len(x) - 1):
	if x[i + 1] * x[i] > 0 and x[i + 1] < 0 and (x[i] < 0):
		b.append(str(x[i]))
		b.append(str(x[i + 1]))
		x.pop(i)
		x.pop(i)
		break
for i in range(len(x)):
	if x[i] > 0:
		b.append(str(x[i]))
		x.pop(i)
		break
for i in range(len(x)):
	c.append(str(x[i]))
print(len(a), ' '.join(a))
print(len(b), ' '.join(b))
print(len(c), ' '.join(c))


lis = list(map(int, input().split()) if input() != '-1' else '')
(a, b, c) = ([], [], [])
if any((i > 0 for i in lis)):
	a.extend([i for i in lis if i > 0])
	if not len([i for i in lis if i < 0]) & 1:
		for i in lis:
			if i < 0:
				c.append(i)
				break
	b.extend([i for i in lis if i < 0 and i not in c])
	c.extend([0 for i in range(lis.count(0))])
else:
	lis = sorted(lis)
	if not len([i for i in lis if i < 0]) & 1:
		b.append(lis[0])
		c.append(lis[1])
		a.extend([i for i in lis if i != 0 and i not in b and (i not in c)])
		c.extend([0 for i in range(lis.count(0))])
	else:
		b.append(lis[0])
		a.extend([i for i in lis if i != 0 and i not in b])
		c.extend([0 for i in range(lis.count(0))])
print(len(b), *b)
print(len(a), *a)
print(len(c), *c)


n = int(input())
l = list(map(int, input().split()))
(neg, pos) = (list(), list())
for i in range(len(l)):
	if l[i] < 0:
		neg.append(l[i])
		l.pop(i)
		break
zero = [0] * l.count(0)
cnt = 0
for i in range(len(l)):
	if l[i] < 0:
		cnt += 1
if cnt % 2 == 0:
	for i in range(len(l)):
		if l[i] != 0:
			pos.append(l[i])
if cnt % 2 == 1:
	for i in range(len(l)):
		if l[i] < 0:
			zero.append(l[i])
			l.pop(i)
			break
	for i in range(len(l)):
		if l[i] != 0:
			pos.append(l[i])
print(len(neg), *neg)
print(len(pos), *pos)
print(len(zero), *zero)


n = int(input())
m = map(int, input().split())
pos = []
neg = []
zero = []
pi = 0
ni = 0
zi = 0
for k in m:
	if k == 0:
		zero.append(k)
	elif k > 0:
		pos.append(k)
	else:
		neg.append(k)
l1 = ''
l2 = ''
l3 = ''
if len(pos) > 0:
	l2 = str(1) + ' ' + str(pos[0])
	pi += 1
else:
	l2 = str(2) + ' ' + str(neg[0]) + ' ' + str(neg[1])
	ni += 2
l1 = str(1) + ' ' + str(neg[ni])
ni += 1
cnt = 0
for i in range(pi, len(pos)):
	l3 += str(pos[i]) + ' '
	cnt += 1
for i in range(ni, len(neg)):
	l3 += str(neg[i]) + ' '
	cnt += 1
for i in range(len(zero)):
	l3 += str(0) + ' '
	cnt += 1
print(l1)
print(l2)
print(str(cnt) + ' ' + l3)


n = int(input())
a = [int(i) for i in input().split()]
negative = [i for i in a if i < 0]
positive = [i for i in a if i > 0]
zero = [i for i in a if i == 0]
if len(positive) == 0:
	positive = negative[:2]
	negative = negative[2:]
if len(negative) % 2 == 0:
	zero.append(negative[0])
	negative = negative[1:]
negative = [len(negative)] + negative
positive = [len(positive)] + positive
zero = [len(zero)] + zero
print(' '.join([str(i) for i in negative]))
print(' '.join([str(i) for i in positive]))
print(' '.join([str(i) for i in zero]))


n = int(input())
a = list(map(int, input().split()))
x2 = max(a)
x1 = min(a)
a.remove(x2)
if x2 == 0:
	print(1, a[0])
	print(2, a[1], a[2])
	print(n - 3, 0, end=' ')
	a.remove(a[0])
	a.remove(a[0])
	a.remove(a[0])
	for i in a:
		print(i, end=' ')
else:
	print(1, x1)
	print(1, x2)
	a.remove(x1)
	print(n - 2, end=' ')
	for i in a:
		print(i, end=' ')


n = int(input())
a = list(map(int, input().split()))
n1 = []
n2 = []
n3 = []
for i in a:
	if i < 0:
		n1.append(i)
	elif i > 0:
		n2.append(i)
	else:
		n3.append(i)
if len(n2) == 0:
	n2.append(n1.pop())
	n2.append(n1.pop())
if len(n1) % 2 == 0:
	n3.append(n1.pop())
print('{} '.format(len(n1)), end='')
for k in n1:
	print('{} '.format(k), end='')
print()
print('{} '.format(len(n2)), end='')
for r in n2:
	print('{} '.format(r), end='')
print()
print('{} '.format(len(n3)), end='')
for t in n3:
	print('{} '.format(t), end='')


import sys
import os
if os.environ.get('GHOST') == 'TRUE':
	sys.stdin = open('name.in')
	sys.stdout = open('name.out', 'w')
zeroes = 0
N = int(input())
A = list(map(int, input().split()))
for ai in A:
	if ai == 0:
		A.remove(ai)
		zeroes += 1
A.sort()
s1 = []
s1.append(A.pop(0))
if s1[0] > 0:
	s1.append(A.pop(0))
s2 = []
s2.append(A.pop())
if s2[0] < 0:
	s2.append(A.pop())
print(len(s1), end=' ')
print(*s1, sep=' ')
print(len(s2), end=' ')
print(*s2, sep=' ')
for i in range(zeroes):
	A.append(0)
print(len(A), end=' ')
print(*A, sep=' ')


def Array(n, lst):
	lst1 = []
	lst2 = []
	lst3 = []
	for i in lst:
		if i < 0:
			lst1.append(i)
		if i > 0:
			lst2.append(i)
		if i == 0:
			lst3.append(i)
	if len(lst2) == 0:
		lst2.append(lst1.pop())
		lst2.append(lst1.pop())
	if len(lst1) % 2 == 0:
		lst3.append(lst1.pop())
	print(len(lst1), ' '.join(map(str, lst1)))
	print(len(lst2), ' '.join(map(str, lst2)))
	print(len(lst3), ' '.join(map(str, lst3)))
n = int(input(''))
lst = list(map(int, input('').split(' ')))
Array(n, lst)