Petya has an array $a$ consisting of $n$ integers. He wants to remove duplicate (equal) elements.

Petya wants to leave only the rightmost entry (occurrence) for each element of the array. The relative order of the remaining unique elements should not be changed.


-----Input-----

The first line contains a single integer $n$ ($1 \le n \le 50$) — the number of elements in Petya's array.

The following line contains a sequence $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 1\,000$) — the Petya's array.


-----Output-----

In the first line print integer $x$ — the number of elements which will be left in Petya's array after he removed the duplicates.

In the second line print $x$ integers separated with a space — Petya's array after he removed the duplicates. For each unique element only the rightmost entry should be left.


-----Examples-----
Input
6
1 5 5 1 6 1

Output
3
5 6 1 

Input
5
2 4 2 4 4

Output
2
2 4 

Input
5
6 6 6 6 6

Output
1
6 



-----Note-----

In the first example you should remove two integers $1$, which are in the positions $1$ and $4$. Also you should remove the integer $5$, which is in the position $2$.

In the second example you should remove integer $2$, which is in the position $1$, and two integers $4$, which are in the positions $2$ and $4$.

In the third example you should remove four integers $6$, which are in the positions $1$, $2$, $3$ and $4$.

Difficulty: EASY

Solutions:
n = int(input())
a = list(map(int, input().split()))
l = len(a)
b = [True] * l
x = 0
d = [100] * 1001
for i in range(l):
	if d[a[i]] == 100:
		x += 1
	else:
		b[d[a[i]]] = False
	d[a[i]] = i
	b[i] = True
print(x)
res = []
for i in range(l):
	if b[i]:
		res.append(a[i])
print(*res)


n = int(input())
a = list(map(int, input().split()))[::-1]
b = []
for i in a:
	if not i in b:
		b.append(i)
print(len(b))
for i in b[::-1]:
	print(i, end=' ')


n = int(input())
l = [int(i) for i in input().split()]
a = [l[-1]]
n -= 2
while n >= 0:
	if l[n] not in a:
		a.append(l[n])
	n -= 1
n = len(a)
print(n)
n -= 1
while n >= 0:
	print(a[n], end=' ')
	n -= 1


a = int(input())
z = list(map(int, input().split()))
from collections import defaultdict
al = defaultdict(int)
for i in range(len(z)):
	al[z[i]] += 1
ans = []
for i in range(len(z)):
	if al[z[i]] == 1:
		ans.append(z[i])
	else:
		al[z[i]] -= 1
print(len(ans))
print(' '.join(map(str, ans)))


n = int(input())
a = list(map(int, input().split()))
for i in range(len(a) - 1, 0, -1):
	if a.count(a[i]) >= 2:
		a.remove(a[i])
print(len(a))
print(*a)


def fill(n):
	return n[0]
n = input()
arr = input().split()
numbers = [int(i) for i in arr]
my_dict = {}
for (i, e) in list(enumerate(numbers)):
	my_dict[e] = i
test = map(fill, sorted(my_dict.items(), key=lambda x: x[1]))
print(len(my_dict))
print(' '.join((str(e) for e in list(test))))


n = input()
arr = list(map(int, input().split()))
arr.reverse()
ans = []
for item in arr:
	if item not in ans:
		ans.append(item)
ans.reverse()
print(len(ans))
for ele in ans:
	print(ele, end=' ')


n = int(input())
L = list(map(int, input().split()))
m = dict()
for x in L:
	m.setdefault(x, 0)
	m[x] += 1
res = []
for x in L:
	m[x] -= 1
	if m[x] == 0:
		res.append(x)
print(len(res))
print(' '.join(map(str, res)))


n = int(input())
a = list(map(int, input().split()))
v = []
a.reverse()
for i in a:
	if i not in v:
		v.append(i)
	else:
		pass
v.reverse()
print(len(v))
for j in v:
	print(j, end=' ')


n = int(input())
d = dict()
x = list(map(int, input().split()))
for i in range(n):
	if x[i] not in d:
		d[x[i]] = 1
	else:
		d[x[i]] += 1
res = []
for i in range(n):
	if d[x[i]] == 1:
		res.append(x[i])
	else:
		d[x[i]] -= 1
print(len(res))
print(' '.join(map(str, res)))


from sys import stdin

def main():
	n = int(stdin.readline())
	l = [int(x) for x in stdin.readline().split()]
	visited = {}
	ans = []
	i = len(l) - 1
	while i >= 0:
		if visited.get(l[i]) == None:
			visited[l[i]] = 1
			ans.append(l[i])
		i -= 1
	print(len(ans))
	for i in range(len(ans)):
		print(ans.pop(), end=' ')
main()


n = int(input())
arr = []
s = input().split()
for i in range(n):
	arr.append(int(s[i]))
arr.reverse()
an = []
for i in arr:
	if i not in an:
		an.append(i)
an.reverse()
print(len(an))
for i in range(len(an)):
	print(an[i], end=' ')


n = int(input())
A = list(map(int, input().split()))
B = []
for i in range(n):
	if A[::-1][i] not in B:
		B.append(A[::-1][i])
print(len(B))
print(' '.join(map(str, B[::-1])))


n = int(input())
li = [int(x) for x in input().split()]
S = set()
ans = []
for item in li[::-1]:
	if item in S:
		continue
	S.add(item)
	ans.append(item)
print(len(ans))
for item in ans[::-1]:
	print(item, end=' ')


n = int(input())
a = [int(i) for i in input().split()]
result = []
for element in a[::-1]:
	if element not in result:
		result.append(element)
print(len(result))
for element in result[::-1]:
	print(element, end=' ')


n = int(input())
a = list(map(int, input().split()))
i = n - 2
s = set(a[n - 1:])
while i != -1:
	if a[i] in s:
		a.pop(i)
	else:
		s.add(a[i])
	i -= 1
print(len(a))
for i in a:
	print(i, end=' ')


import sys
import math
import bisect

def main():
	n = int(input())
	A = list(map(int, input().split()))
	s = set()
	B = []
	for a in A[::-1]:
		if a not in s:
			B.append(a)
			s.add(a)
	print(len(B))
	print(' '.join(list((str(a) for a in B[::-1]))))
main()


n = int(input())
numbers = list(map(int, input().split()))
numbers.reverse()
result = []
for x in numbers:
	if x not in result:
		result.insert(0, x)
print(len(result))
for i in result:
	print(i, end=' ')


N = int(input())
arr = list(map(int, input().split()))
print(len(set(arr)))
for i in range(N - 1, 0, -1):
	for j in range(i):
		if arr[i] == arr[j]:
			arr[j] = -20
for i in range(N):
	if arr[i] > 0:
		print(arr[i], end=' ')


a = int(input())
l = [int(x) for x in input().split()]
l2 = []
for i in range(len(l)):
	l1 = l[i + 1:]
	if not l[i] in l1:
		l2.append(l[i])
print(len(l2))
for i in l2:
	print(i, end=' ')


n = int(input())
a = list(map(int, input().split()))
b = a[:]
for i in a:
	while b.count(i) > 1:
		b.remove(i)
print(len(b))
print(*b)


n = int(input())
l = list(map(int, input().split()))
s = set(l)
i = 0
while len(l) != len(s):
	if l.count(l[i]) > 1:
		l.remove(l[i])
	else:
		i += 1
print(len(l))
print(*l)


n = int(input())
l = list(map(int, input().split()))
s = set(l)
list1 = []
for i in range(len(l)):
	if l[len(l) - i - 1] not in list1:
		list1.append(l[len(l) - i - 1])
print(len(list1))
list1.reverse()
for i in list1:
	print(i, end=' ')


input()
l = input().split()
l1 = l.copy()
for x in l1:
	if x in l[l.index(x) + 1:]:
		l.remove(x)
print(len(l))
print(*l)


n = int(input())
l = list(map(int, input().split()))
li = []
i = 0
while i < len(l):
	if l.count(l[i]) > 1:
		l.pop(i)
		i -= 1
	else:
		li.append(l[i])
	i += 1
print(len(li))
for i in range(len(li)):
	print(li[i], end=' ')


n = input()
l = list(map(int, input().split(' ')))
l = l[::-1]
ans = []
for i in l:
	if i in ans:
		continue
	else:
		ans.append(i)
ans = ans[::-1]
print(len(ans))
print(*ans)


import math
from collections import defaultdict, deque
import bisect
x = int(input())
a = list(map(int, input().split()))
b = []
a = a[::-1]
for i in a:
	if i not in b:
		b.append(i)
print(len(set(a)))
print(*b[::-1])


n = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(n - 1, -1, -1):
	if a[i] not in ans:
		ans.insert(0, a[i])
print(len(ans))
print(*ans)


n = [int(x) for x in input().rstrip().split()][0]
data = [int(x) for x in input().rstrip().split()]
result = []
for i in range(len(data) - 1, -1, -1):
	if data[i] not in result:
		result.append(data[i])
result.reverse()
print(len(result))
print(' '.join(map(str, result)))


n = int(input())
a = list(map(int, input().split()))
print(len(set(a)))
l = []
i = n - 1
while i > -1:
	if a[i] not in l:
		l.append(a[i])
	i -= 1
l.reverse()
for r in l:
	print(r, end=' ')


def main():
	n = int(input())
	arr = [int(x) for x in input().split()]
	s = set()
	narr = []
	for x in arr[::-1]:
		if x not in s:
			narr.append(x)
			s.add(x)
	narr = narr[::-1]
	print(len(narr))
	print(' '.join([str(x) for x in narr]))
main()


n = int(input())
data = []
p = input().split(' ')
for i in range(0, n):
	p[i] = int(p[i])
	data.append(p[i])
c = []
for i in range(0, max(data) + 1):
	c.append(0)
for i in range(0, max(data) + 1):
	for j in range(0, n):
		if data[j] == i:
			c[i] += 1
			continue
k = max(data) + 1
for i in range(0, k):
	for j in range(0, n):
		if c[i] > 1:
			if data[j] == i:
				data[j] = 0
				c[i] += -1
jlh = 0
for i in range(0, n):
	if data[i] == 0:
		jlh += 1
print(len(data) - jlh)
for i in range(0, len(data)):
	if data[i] != 0:
		print(data[i], end=' ')


n = int(input())
a = list(map(int, input().split()))
newList = []
for element in a[::-1]:
	if element not in newList:
		newList.append(element)
	else:
		a.remove(element)
print(len(a))
a = ' '.join(map(str, a))
print(a)


a = int(input())
S = [int(i) for i in input().split()]
b = list(reversed(list(set(list(reversed(S))))))
L = []
print(len(b))
for i in range(a - 1, -1, -1):
	if b.count(S[i]) != 0:
		L.append(S[i])
		b.remove(S[i])
for i in range(len(L) - 1, -1, -1):
	print(L[i], end=' ')


n = int(input())
l = [int(i) for i in input().split()]
res = []
for i in range(n):
	if l[i] in res:
		res.remove(l[i])
		res.append(l[i])
	else:
		res.append(l[i])
print(len(res))
print(*res)


from collections import *
x = Counter()
input()
v = reversed(list(map(int, input().split())))
a = []
for i in v:
	if i not in x:
		x[i] += 1
		a.append(i)
print(len(a))
print(*reversed(a))


n = int(input())
arr = list(map(int, input().split()))
arr.reverse()
res = []
for i in arr:
	if i not in res:
		res.append(i)
print(len(res))
res.reverse()
for i in res:
	print(i, end=' ')


n = int(input())
a = [int(i) for i in input().split()]
d = set()
a = a[::-1]
l = []
for i in range(0, len(a)):
	if a[i] in d:
		pass
	else:
		l.append(a[i])
		d.add(a[i])
print(len(l))
print(*l[::-1])


class Solution:

	def remove(self, a):
		b = []
		i = len(a) - 1
		n = len(a)
		while i >= 0:
			if a[i] not in b:
				b.append(a[i])
			i = i - 1
		return b

def printc(x):
	i = len(x) - 1
	while i >= 0:
		print(x[i], end=' ')
		i = i - 1
x = input()
a = [int(x) for x in input().split()]
t = Solution()
print(len(t.remove(a)))
printc(t.remove(a))


from copy import *
n = int(input())
arr = list(map(int, input().split()))
arr1 = deepcopy(arr)
for i in arr:
	count = arr1.count(i)
	j = 0
	while count != 1:
		arr1.remove(i)
		count = count - 1
print(len(arr1))
for i in arr1:
	print(i, end=' ')
print()


n = int(input())
a = list(map(int, input().split()))
a = a[::-1]
b = []
for i in range(len(a)):
	flag = 0
	for j in range(i):
		if a[i] == a[j]:
			flag = 1
	if flag == 0:
		b.append(a[i])
b = b[::-1]
print(len(b))
for i in b:
	print(i, end=' ')


n = int(input())
array_input = input().split()
duplicate_list = []
for elements in array_input:
	if elements not in duplicate_list:
		duplicate_list.append(elements)
	else:
		duplicate_list.remove(elements)
		duplicate_list.append(elements)
print(len(duplicate_list))
for i in duplicate_list:
	print(i, end=' ')


used = set()
n = int(input())
massif = [int(a) for a in input().split()]
ans = []
for a in range(n - 1, -1, -1):
	if massif[a] not in used:
		used.add(massif[a])
		ans.append(massif[a])
print(len(ans))
for a in range(len(ans) - 1, -1, -1):
	print(ans[a], end=' ')


n = int(input())
arr = list(map(int, input().split()))
arr1 = arr
nb = 0
for i in range(len(arr)):
	for j in range(len(arr)):
		if arr[i] == arr[j] and i != j:
			arr1[i] = 0
			nb = nb + 1
print(len(arr1) - nb)
for i in arr1:
	if i != 0:
		print(i, end=' ')


n = int(input())
l = []
a = list(map(int, input().strip().split(' ')))
for i in reversed(a):
	if i in l:
		continue
	else:
		l.append(i)
print(len(l))
for j in l[::-1]:
	print(j, end=' ')


n = int(input())
lst = [int(x) for x in input().split()]
ans = []
for i in range(n - 1, -1, -1):
	if lst[i] not in ans:
		ans.append(lst[i])
print(len(ans))
for i in range(len(ans) - 1, -1, -1):
	print(ans[i], end=' ')


input()
(visited, A) = (set(), [])
for a in reversed(input().split()):
	if a not in visited:
		visited.add(a)
		A.append(a)
print(len(A))
print(*reversed(A))


n = int(input())
a = [int(i) for i in input().split()]
a.reverse()
d = []
for i in a:
	if i not in d:
		d.append(i)
d.reverse()
print(len(d))
for i in d:
	print(i, end=' ')


n = int(input())
a = list(map(int, input().split()))
b = [0] * 1001
c = list()
for i in range(n - 1, -1, -1):
	if b[a[i]] == 0:
		b[a[i]] = 1
		c.append(a[i])
print(len(c))
print(' '.join(map(str, c[::-1])))


n = int(input())
a = input().split()
l = []
for i in a[::-1]:
	if i not in l:
		l.append(i)
l.reverse()
print(len(l))
print(' '.join(l))


n = int(input())
stream = input()
nums = [int(i) for i in stream.split()]
sol = set([])
res = []
for i in reversed(nums):
	if i not in sol:
		sol.add(i)
		res.insert(0, i)
print(len(sol))
length = len(res)
for i in range(length):
	print(res[i], end='')
	if i != length - 1:
		print(' ', end='')


n = int(input())
li = list(map(int, input().split()))
li1 = []
for i in li[::-1]:
	if i not in li1:
		li1.append(i)
print(len(li1))
print(*li1[::-1])


n = int(input())
a = list(map(int, input().split()))
b = [v for (i, v) in enumerate(a) if v not in a[i + 1:]]
print(len(b))
print(*b)


from sys import stdin, stdout
len_array = int(stdin.readline())
array = list(map(int, stdin.readline().split(' ')))
rem_array = list()
container = set(array)
i = len_array - 1
while i >= 0:
	if array[i] in container:
		container.remove(array[i])
		rem_array.append(array[i])
	i -= 1
j = len(rem_array) - 1
print(j + 1)
while j >= 0:
	print(rem_array[j], end=' ')
	j -= 1


n = int(input())
xs = [int(x) for x in input().split()]
sol = []
for x in xs[::-1]:
	if x not in sol:
		sol.append(x)
print(len(sol))
print(' '.join(list(map(str, sol[::-1]))))


n = int(input())
a = [int(s) for s in input().split(' ')]
x = [str(c) for (i, c) in enumerate(a) if c not in a[i + 1:]]
print(len(x))
print(' '.join(x))


n = int(input())
p = [0 for i in range(2000)]
a = list(map(int, input().split()))
for i in range(n - 1, -1, -1):
	if p[a[i]] == 0:
		p[a[i]] = 1
	else:
		a[i] = -1
print(sum(p))
for i in range(n):
	if a[i] != -1:
		print(a[i], end=' ')


from collections import Counter
n = int(input())
arr = input().split(' ')
arr = [int(i) for i in arr]
c = Counter(arr)
temp = c.most_common(n)
for i in temp:
	for j in range(i[1] - 1):
		arr.remove(i[0])
print(len(temp))
new = ''
for i in arr:
	new += str(i) + ' '
print(new)


n = int(input())
a = [int(a) for a in input().split()]
b = []
for _ in range(n):
	if a[_] not in a[_ + 1:]:
		b.append(a[_])
print(len(b))
print(*b)


def solve(arr):
	seen = set()
	uniq = []
	for x in reversed(arr):
		if x not in seen:
			seen.add(x)
			uniq.append(x)
	print(len(uniq))
	print(' '.join(map(str, reversed(uniq))))
if '__main__' == __name__:
	input()
	solve(list(map(int, input().strip().split(' '))))


size = int(input())
array = input().split(' ')
new_array = []
new_set = set()
for i in range(size - 1, -1, -1):
	if array[i] not in new_set:
		new_array = [array[i]] + new_array
		new_set.add(array[i])
print(len(new_array))
for el in new_array:
	print(el, end=' ')
print()


n = int(input())
L = list(map(int, input().split()))
K = [L[-1]]
for i in range(2, n + 1):
	if L[-i] not in K:
		K = [L[-i]] + K
print(len(K))
print(' '.join(map(str, K)))


n = int(input())
a = [int(x) for x in input().split()]
b = []
for i in range(n):
	if a[n - i - 1] not in b:
		b.append(a[n - i - 1])
print(len(b))
for i in b[::-1]:
	print(i, end=' ')


z = input
import math
h = int(z())
l = list(map(int, z().split()))[::-1]
p = []
for i in l:
	if i not in p:
		p.append(i)
print(len(p))
print(*p[::-1])


num_ints = input()
num_array = input()
num_array = num_array.split(' ')
counts = {}
for i in range(len(num_array) - 1, -1, -1):
	if num_array[i] in counts:
		del num_array[i]
	else:
		counts[num_array[i]] = 1
print(len(num_array))
for i in num_array:
	print(i, end=' ')


n = int(input())
ls = list(map(int, input().split()))
op = []
for item in ls[::-1]:
	if item not in op:
		op.append(item)
print(len(op))
print(*op[::-1])


def main():
	n = int(input())
	a = list(map(int, input().split(' ')))
	check = [False for i in range(10001)]
	counter = 0
	for i in range(n - 1, -1, -1):
		if check[a[i]]:
			counter = counter + 1
			a[i] = -1
		else:
			check[a[i]] = True
	print(n - counter)
	for i in a:
		if i > 0:
			print(i, end=' ')
main()


a = int(input())
b = list(map(int, input().split(' ')))
first_occurance = {}
for i in range(len(b)):
	first_occurance[b[i]] = i
c = sorted(set(b), key=lambda x: first_occurance[x])
print(len(c))
for i in c:
	print(i, end=' ')


n = int(input())
array = list(map(int, input().strip().split()))
exist = [False] * 1001
array2 = []
for lol in range(n - 1, -1, -1):
	if exist[array[lol]]:
		continue
	exist[array[lol]] = True
	array2.append(array[lol])
print(len(array2))
for lol in range(len(array2) - 1, -1, -1):
	print(array2[lol], end=' ')


n = int(input())
a = list(map(int, input().split()))
rev = []
s = set()
for i in range(len(a) - 1, -1, -1):
	if a[i] not in s:
		rev.append(a[i])
		s.add(a[i])
print(str(len(rev)))
print(*rev[::-1])


n = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(n - 1, -1, -1):
	if a[i] not in ans:
		ans.append(a[i])
ans.reverse()
print(len(ans))
print(*ans)


n = int(input())
mass = list(map(int, input().split()))
i = 0
while i != len(mass):
	if mass[i] in mass[i + 1:]:
		del mass[i]
	else:
		i += 1
print(len(mass))
for i in range(len(mass)):
	print(mass[i], end=' ')


b = int(input())
c = [int(x) for x in input().split()]
c.reverse()
a = {x for x in c}
print(len(a))
t = []
for x in c:
	if x in a:
		a.remove(x)
		t = t + [x]
t.reverse()
for x in t:
	print(x, end=' ')


t = int(input())
p = list(map(int, input().split()))
q = set(p)
for i in q:
	if p.count(i) > 1:
		for j in range(p.count(i) - 1):
			p.remove(i)
print(len(q))
print(*p, sep=' ')


n = int(input())
a = []
s = set()
c = input()
b = c[::-1].split(' ')
for nu in b:
	if nu not in s:
		a.append(nu)
	s.add(nu)
print(len(a))
print(str.join(' ', a)[::-1])


T = int(input())
x = list(map(int, input().split()))
a = set([])
final = []
for i in range(T - 1, -1, -1):
	if x[i] in a:
		continue
	else:
		a.add(x[i])
		final.append(x[i])
print(len(final))
for i in range(len(final) - 1, -1, -1):
	print(final[i], end=' ')


n = int(input())
numbers = list(map(int, input().split()))
indices = {}
for x in range(n):
	a = numbers[x]
	if a not in indices:
		indices[a] = []
	indices[a].append(x)
for index in indices.values():
	for x in range(len(index) - 1):
		numbers[index[x]] = 0
numbers = list(filter(lambda x: x != 0, numbers))
print(len(numbers))
print(' '.join(map(str, numbers)))


n = int(input())
a = input().split()
t = []
ans = []
for i in range(n):
	if not a[n - i - 1] in t:
		t.append(a[n - i - 1])
		ans.append(a[n - i - 1])
print(len(ans))
for i in range(len(ans)):
	print(ans[len(ans) - i - 1], end=' ')


def main():
	(_, s, r) = (input(), set(), [])
	for a in map(int, input().split()[::-1]):
		if a not in s:
			s.add(a)
			r.append(a)
	print(len(r))
	print(*r[::-1])
main()


n = int(input())
A = list(map(int, input().split()))
met = set()
ans = []
for i in range(len(A) - 1, -1, -1):
	if A[i] not in met:
		met.add(A[i])
		ans += [A[i]]
print(len(ans))
for i in range(len(ans) - 1, -1, -1):
	print(ans[i], end=' ')


n = int(input())
array = list(map(int, input().split()))
arrayAux = []
saida = ''
for i in range(n):
	if not array[i] in array[i + 1:n]:
		arrayAux.append(array[i])
print(len(arrayAux))
print(' '.join(map(str, arrayAux)))


n = int(input())
a = list(map(int, input().split()))
s = set()
res = []
for num in reversed(a):
	if num not in s:
		res.append(num)
	s.add(num)
print(len(s))
res.reverse()
print(*res)


n = int(input())
arr = list(map(int, input().strip().split(' ')))
freq = [-1 for i in range(1001)]
for i in range(n):
	freq[arr[i]] = i
brr = [-1 for i in range(1001)]
for i in range(1001):
	if freq[i] != -1:
		brr[freq[i]] = i
cnt = 0
for i in range(1001):
	if brr[i] != -1:
		cnt += 1
print(cnt)
for i in range(1001):
	if brr[i] != -1:
		print(brr[i], end=' ')


from sys import stdin

def list_int():
	s = stdin.readline()[:-1]
	return list(map(int, s.split()))

def list_float():
	s = stdin.readline()[:-1]
	return list(map(float, s.split()))

def list_str():
	s = stdin.readline()[:-1]
	return list(s.split())

def space_int():
	s = stdin.readline()[:-1]
	return map(int, s.split())

def space_float():
	s = stdin.readline()[:-1]
	return map(float, s.split())

def space_str():
	s = stdin.readline()[:-1]
	return s.split()

def _int():
	s = stdin.readline()[:-1]
	return int(s)

def _str():
	s = stdin.readline()[:-1]
	return s

def _float():
	s = stdin.readline()[:-1]
	return float(s)

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

def _sieve(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
	prime[0] = False
	prime[1] = False
	return prime
alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
maxi = -2 ** 32
mini = 2 ** 32
mod = 10 ** 9 + 7
n = _int()
a = list_int()[::-1]
s = set()
l = []
for i in range(n):
	if a[i] not in s:
		s.add(a[i])
		l.append(a[i])
l = l[::-1]
print(len(l))
print(*l)


t = int(input())
a = list(map(int, input().split()))
print(len(set(a)))
for i in range(0, len(a)):
	if a.count(a[i]) > 1:
		a[i] = ' '
for i in range(0, len(a)):
	if a[i] != ' ':
		print(a[i], end=' ')


n = int(input())
l = [int(x) for x in input().split()]
l1 = []
notRepeated = 1
for i in range(n):
	notRepeated = 1
	for j in range(len(l1)):
		if l[n - i - 1] == l1[j]:
			notRepeated = 0
			break
	if notRepeated:
		l1.append(l[n - i - 1])
print(len(l1))
for i in range(len(l1)):
	print(l1[len(l1) - 1 - i], end=' ')


n = int(input())
l = []
l1 = []
l = list(map(int, input().split()))[::-1]
for i in l:
	if i not in l1:
		l1.append(i)
print(len(l1))
print(*l1[::-1])


n = int(input())
ans = 0
s = list(map(int, input().split()))
for i in range(n - 1, 0, -1):
	for j in range(i - 1, -1, -1):
		if s[j] == s[i]:
			s[j] = 0
for i in range(n - 1, -1, -1):
	if s[i] == 0:
		s.pop(i)
	else:
		ans += 1
print(ans)
for i in range(len(s)):
	print(s[i], end=' ')


input()
lst = [int(i) for i in input().split(' ')]
lst = list(reversed(lst))
ans = []
for i in lst:
	if ans.count(i) == 0:
		ans.insert(0, i)
print(len(ans))
for i in ans:
	print(i, end=' ')


t = int(input())
a = list(map(int, input().split()))
b = []
for i in a[::-1]:
	if a.count(i) > 1 and i not in b:
		b.append(i)
		a.remove(i)
	if a.count(i) == 1 and i not in b:
		b.append(i)
print(len(b))
for j in b[::-1]:
	print(j, end=' ')


n = int(input())
original_arr = [int(el) for el in input().split(' ')]
new_arr = []
original_arr.reverse()
for original_el in original_arr:
	if original_el not in new_arr:
		new_arr.append(original_el)
new_arr.reverse()
print(len(new_arr))
line = ''
for el in new_arr:
	line += str(el) + ' '
print(line[:len(line) - 1])


def main():
	n = int(input())
	num = list(map(int, input().split()))
	h = {}
	ans = []
	for i in range(n - 1, -1, -1):
		if num[i] in h:
			continue
		else:
			h[num[i]] = 1
			ans.append(num[i])
	ans.reverse()
	print(len(ans))
	print(*ans)
main()


n = int(input())
list1 = [int(x) for x in input().split()]
answer = []
for i in range(len(list1)):
	if list1[i] not in list1[i + 1:]:
		answer.append(list1[i])
print(len(answer))
print(*answer)


n = int(input())
s = 0
a = list(map(int, input().split()))
while 1 > 0:
	if s > len(a) - 1:
		break
	k = 0
	for i in range(n):
		if i != s and a[s] == a[i]:
			del a[min(i, s)]
			n = n - 1
			k = 1
			break
	if s == len(a) or s > len(a):
		break
	if k == 0:
		s = s + 1
print(len(a))
for i in range(len(a)):
	print(a[i], end=' ')


n = int(input())
l = [int(x) for x in input().split()]
s = []
for i in range(n - 1, -1, -1):
	if str(l[i]) not in s:
		s.append(str(l[i]))
s.reverse()
print(len(s))
print(' '.join(s))


n = int(input())
ar = list(map(int, input().split()))
ar = ar[::-1]
d = {}
for i in ar:
	if i not in d:
		d[i] = 1
	else:
		d[i] += 1
l = list(d.keys())
print(len(set(ar)))
for i in l[::-1]:
	print(i, end=' ')


n = int(input())
a = list(map(int, input().split()))
b = list(set(a))
i = 0
c = []
j = len(a) - 1
while j >= 0:
	if a[j] in b:
		c.append(a[j])
		b.remove(a[j])
	else:
		j -= 1
c.reverse()
print(len(c))
for i in c:
	print(i, end=' ')


n = int(input())
a = input()
a = ''.join(reversed(a))
s = list(map(str, a.split(' ')))
c = list()
for i in range(0, n):
	if not s[i] in c:
		c.append(str(s[i]))
print(len(c))
c = ' '.join(c)
c = ''.join(reversed(c))
print(c)


N = int(input())
L = list(map(int, input().split(' ')))
print(len(set(L)))
for i in range(0, N):
	L1 = L[i + 1:]
	if L[i] not in L1:
		print(L[i], end=' ')
print()


n = int(input())
nums = input().strip().split()
nums.reverse()
res = []
d = {}
for item in nums:
	if item not in d:
		d[item] = 1
		res.append(item)
res.reverse()
print(len(res))
print(' '.join(res))


n = int(input())
ar = list(map(int, input().split()))
dic = {}
for i in range(n - 1, -1, -1):
	if ar[i] not in dic:
		dic[ar[i]] = 1
	else:
		ar[i] = -1
l = []
for i in ar:
	if i != -1:
		l.append(i)
print(len(l))
for i in l:
	print(i, end=' ')
print('')


from collections import *
n = int(input())
a = list(map(int, input().split()))
b = []
a = list(reversed(a))
for i in a:
	if i not in b:
		b.append(i)
print(len(b))
b = list(reversed(b))
print(*b)


n = int(input())
h = [int(k) for k in input().split()]
e = []
for i in range(n):
	if h[i] in e:
		e.remove(h[i])
		e.append(h[i])
	else:
		e.append(h[i])
print(len(e))
for x in e:
	print(x, end=' ')


x = int(input())
s = [int(n) for n in input().split()]
z = []
for n in range(x):
	if s[x - 1 - n] not in z:
		z.append(s[x - 1 - n])
print(len(z))
z = z[::-1]
for n in z:
	print(n, end=' ')


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

def ss():
	return [x for x in input()]

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

def mi():
	return map(int, input().split())
a = ii()
c = si()[::-1]
s = []
for i in c:
	if not i in s:
		s.append(i)
s.reverse()
print(len(s))
print(*s)


n = int(input())
l = list(map(int, input().split()))
l2 = []
for i in range(n - 1, -1, -1):
	if l[i] not in l2:
		l2.insert(0, l[i])
print(len(l2))
for x in l2:
	print(x, end=' ')
print()


input()
s = list(map(int, input().split()))
s.reverse()
out = []
for i in s:
	if i not in set(out):
		out.append(i)
print(len(out))
print(*out[::-1])


n = int(input())
l = [int(i) for i in input().split()]
l.reverse()
duplicates = []
for i in l:
	if i not in duplicates:
		duplicates.append(i)
duplicates.reverse()
print(len(duplicates))
print(*duplicates)


n = int(input())
a = list(map(int, input().split()))
a = a[::-1]
l = list()
for x in a:
	if not x in l:
		l.append(x)
print(len(l))
print(' '.join([str(x) for x in l[::-1]]))


n = int(input())
li = list(map(int, input().split()))
s = []
for i in range(n):
	if li[n - 1 - i] not in s:
		s.append(li[n - 1 - i])
n = len(s)
print(n)
for i in range(n):
	print(s[n - 1 - i], end=' ')


n = int(input())
a = list(map(str, input().split()))
s = []
for i in range(n):
	if a.count(a[i]) < 2 and a[i] != ' ':
		s.append(a[i])
	else:
		a[i] = ' '
print(len(s))
print(*s)


import sys
input = sys.stdin.readline
N = int(input())
L = list(map(int, input().split()))
L = L[::-1]
there = set()
LNEW = []
for x in L:
	if x not in there:
		there.add(x)
		LNEW.append(x)
print(len(LNEW))
print(' '.join([str(x) for x in LNEW[::-1]]))


n = int(input())
mp = dict()
ls = [int(i) for i in input().split()]
for (i, j) in enumerate(ls):
	mp[j] = i
ans = [-1] * len(ls)
for i in mp.keys():
	ans[mp[i]] = i
print(len(mp.keys()))
for i in ans:
	if i != -1:
		print(i, end=' ')


from sys import stdin

def main():
	(n,) = stdin_get_ints_from_line()
	a = stdin_get_ints_list_from_line()
	result = []
	dups = set()
	for elem in reversed(a):
		if elem not in dups:
			dups.add(elem)
			result.append(elem)
	print(len(result))
	print(' '.join((str(x) for x in reversed(result))))

def stdin_get_ints_from_line():
	return (int(x) for x in stdin.readline().strip().split(' '))

def stdin_get_ints_list_from_line():
	return list((int(x) for x in stdin.readline().strip().split(' ')))

def stdin_get_string_from_line():
	return stdin.readline().strip()
main()


import sys
input = sys.stdin.readline
L = lambda : list(map(int, input().split()))
M = lambda : map(int, input().split())
n = int(input())
l = L()
s = list(set(l))
g = []
for i in range(len(s)):
	g.append(n - 1 - l[::-1].index(s[i]))
g.sort()
print(len(s))
for i in range(len(g)):
	print(l[g[i]], end=' ')


n = int(input())
a = list(map(int, input().split()))
used = {}
ans = []
for ai in reversed(a):
	if ai not in used:
		ans.append(ai)
		used[ai] = True
print(len(ans))
print(' '.join(map(str, list(reversed(ans)))))


x = int(input())
l = []
s = list(map(int, input().split()))
s.reverse()
for i in s:
	if i not in l:
		l = l + [i]
l.reverse()
print(len(l))
print(' '.join(map(str, l)))


n = int(input())
l = list(map(int, input().split()))
s = set(l)
indexes = [len(l) - l[::-1].index(x) - 1 for x in s]
indexes = sorted(indexes)
print(len(s))
print(' '.join([str(l[i]) for i in indexes]))


n = int(input())
a = [int(i) for i in input().split()]
b = []
ans = []
for i in reversed(range(n)):
	if not a[i] in b:
		b.append(a[i])
		ans = [a[i]] + ans
print(len(ans))
for i in range(len(ans)):
	if i != len(ans) - 1:
		print(ans[i], end=' ')
	else:
		print(ans[i])


a = int(input())
b = list(map(int, input().split()))
b.reverse()
for i in range(len(b)):
	for j in range(i + 1, len(b)):
		if b[i] == b[j]:
			b[j] = 'x'
print(len(b) - b.count('x'))
b.reverse()
for i in range(len(b)):
	if b[i] != 'x':
		print(b[i], end=' ')


n = int(input())
a = list(map(int, input().split()))
di = {}
for i in range(n):
	di[a[i]] = i
x = sorted(di.items(), key=lambda x: x[1])
print(len(x))
print(' '.join((str(m[0]) for m in x)))


n = int(input())
a = list(map(int, input().split()))
s = set()
for i in range(n - 1, -1, -1):
	if a[i] in s:
		del a[i]
	else:
		s.add(a[i])
print(len(a))
print(*a)


n = int(input())
p = list(map(int, input().split()))
r = []
for i in range(n - 1, -1, -1):
	if not p[i] in r:
		r.insert(0, p[i])
s = len(r)
print(s)
for i in r:
	print(i, end=' ')
print()


n = int(input())
l = [int(x) for x in input().split()]
l = l[::-1]
p = []
for i in range(n):
	q = l[0:i]
	if q.count(l[i]) == 0:
		p.append(l[i])
print(len(p))
for i in reversed(range(len(p))):
	print(p[i], end=' ')


def reverse(lst):
	buff_lst = list()
	for j in range(len(lst) - 1, -1, -1):
		buff_lst.append(lst[j])
	return buff_lst
n = int(input())
orig_arr = reverse([int(elem) for elem in input().split(' ')])
new_arr = list()
for i in orig_arr:
	if i not in new_arr:
		new_arr.append(i)
print(len(new_arr))
print(' '.join(reverse([str(elem) for elem in new_arr])))


n = int(input())
arr = list(map(int, input().split()))
ul = []
for i in reversed(arr):
	if i not in ul:
		ul.append(i)
print(len(ul))
print(' '.join(map(str, reversed(ul))))


l = int(input())
n = list(map(int, input().split()))[::-1]
k = set(n)
e = len(k)
u = []
for i in range(len(n)):
	if n[i] in k:
		u.append(n[i])
		k.remove(n[i])
print(e)
print(*u[::-1], sep=' ')


n = input()
array = input().split(' ')
check = []
for i in array[::-1]:
	if i in check:
		pass
	else:
		check.append(i)
check = ' '.join(check[::-1])
print(len(check.split(' ')))
print(check)


input()
dup = list(map(int, input().split()))
print(len(set(dup)))
nondup = []
for num in reversed(range(len(dup))):
	if dup[num] not in nondup:
		nondup.insert(0, dup[num])
for num in nondup:
	print(num, end=' ')


n = int(input())
c = list(map(int, input().split()))
c = c[::-1]
print(len(set(c)))
visited = []
for i in c:
	if i not in visited:
		visited.append(i)
print(*visited[::-1])


a = int(input())
c = []
b = list(map(int, input().split()))
for i in range(len(b) - 1, -1, -1):
	if b[i] not in c:
		c.append(b[i])
print(len(c))
print(*reversed(c), end=' ')


n = input()
a = []
x = map(int, input().split())
for i in x:
	while i in a:
		del a[a.index(i)]
	a.append(i)
print(len(a))
print(*a)


n = int(input())
a = list(map(int, input().split()))
a = a[::-1]
hm = [0] * 10000
ans = []
for i in a:
	if hm[i] == 0:
		ans.append(i)
		hm[i] = 1
print(len(ans))
for i in ans[::-1]:
	print(i, end=' ')


n = int(input())
l = list(map(int, input().split()))
g = list(set(l))
ans = []
for i in g:
	e = 0
	for j in range(n - 1, -1, -1):
		if l[j] == i and e == 0:
			e += 1
		elif l[j] == i and e != 0:
			l[j] = 0
for k in l:
	if k != 0:
		ans.append(k)
print(len(ans))
print(*ans)


n = int(input())
a = list(map(int, input().split()))
vs = 1001 * [0]
r = []
for i in range(n - 1, -1, -1):
	vs[a[i]] += 1
	if vs[a[i]] == 1:
		r.append(a[i])
print(len(r))
print(*r[::-1])


n = int(input())
a = list(map(int, input().split(' ')))
uni = {}
for i in range(len(a)):
	uni[a[i]] = i
s = ''
print(len(uni.keys()))
for i in range(len(a)):
	if uni[a[i]] == i:
		print(a[i], end=' ')


n = int(input())
array = []
a = input()
array = a.split(' ')
array.reverse()
array = dict.fromkeys(array)
ARRAY = []
for x in array:
	ARRAY.append(x)
ARRAY.reverse()
print(len(ARRAY))
for x in ARRAY:
	print(x, end=' ')


n = int(input())
a = list(map(int, input().split()))
i = 1
while -i >= -len(a):
	while a[-i] in a[0:len(a) - i]:
		a.remove(a[-i])
	i += 1
print(len(a))
print(*a)


input()
n = [int(x) for x in input().strip().split()][::-1]
seen = set()
out = []
for i in n:
	if i in seen:
		continue
	out.append(str(i))
	seen.add(i)
print(len(out))
print(' '.join(out[::-1]))


n = int(input())
a = [int(s) for s in input().split()]
dic = {}
a0 = []
for i in range(n - 1, -1, -1):
	if not dic.get(a[i]):
		a0.append(a[i])
	dic[a[i]] = 1
print(len(a0))
print(*reversed(a0), sep=' ')


n = int(input())
a = [int(s) for s in input().split(' ')]
s = []
i = len(a) - 1
while i >= 0:
	if s.count(a[i]) == 0:
		s.append(a[i])
	i -= 1
i = len(s) - 1
print(i + 1)
string = ''
while i >= 0:
	string += str(s[i]) + ' '
	i -= 1
print(string)


n = int(input())
k = list(map(int, input().split()))
k1 = []
for i in range(len(k) - 1, -1, -1):
	l = 0
	for j in range(len(k1)):
		if k[i] == k1[j]:
			l = 1
			break
	if l == 0:
		k1.append(k[i])
print(len(k1))
for i in range(len(k1) - 1, -1, -1):
	print(k1[i], end=' ')


a = []
n = int(input())
l = list(map(int, input().split()))
for x in range(1, n + 1):
	if l[-x] not in a:
		a.append(l[-x])
print(len(a))
for x in range(1, len(a) + 1):
	print(a[-x], end=' ')


n = int(input())
a = list(map(int, input().split()))
a.reverse()
ans = []
for i in a:
	if ans.count(i) == 0:
		ans.append(i)
ans.reverse()
print(len(ans))
for i in ans:
	print(i, end=' ')


x = int(input())
x1 = [int(n) for n in input().split()]
res = []
for i in range(x):
	if x1[i] not in x1[i + 1:x]:
		res.append(x1[i])
print(len(res))
print(' '.join(map(str, res)))


def removeDuplicate(element):
	final_list = []
	for num in element:
		if num not in final_list:
			final_list.append(num)
	final_list.reverse()
	return final_list
n = int(input())
a = [int(x) for x in input().split()]
if n < 1 or n > 50:
	raise ValueError('1<=n<=50')
if max(a) > 1000 or min(a) < 1:
	raise ValueError('1<=a<=1000')
a.reverse()
print(len(removeDuplicate(a)))
for x in removeDuplicate(a):
	print(x, end=' ')


n = int(input())
ns = [int(x) for x in input().split()]
nss = list(ns)
d = {}
for i in range(n):
	if ns[i] in d:
		ns[d[ns[i]]] = -1
	d[ns[i]] = i
ans = [nss[i] for i in range(n) if ns[i] != -1]
print(len(ans))
print(*ans, sep=' ')


input()
a = input().split()
b = set()
c = []
for i in a[::-1]:
	if i not in b:
		b.add(i)
		c.insert(0, i)
print(len(c))
print(' '.join(c))


n = int(input())
a = list(map(int, input().split()))
ind = []
for i in range(n):
	for j in range(i + 1, n):
		if a[i] == a[j]:
			ind.append(i)
			break
for i in range(len(ind) - 1, -1, -1):
	a.pop(ind[i])
print(len(a))
print(*a)


n = int(input())
list2 = []
list1 = list(map(int, input().split()))
for i in range(len(list1)):
	if list1[i] in list1[i + 1:]:
		list2.append(i)
print(n - len(list2))
for i in range(len(list1)):
	if i not in list2:
		print(list1[i], end=' ')


n = int(input())
a = list(map(int, input().split()))
res = []
items = set()
for x in reversed(a):
	if not x in items:
		res.append(x)
		items.add(x)
res.reverse()
print(len(res))
print(' '.join(map(str, res)))


def main():
	input()
	numbers = [int(_) for _ in input().split()]
	numbers.reverse()
	uniques = list(dict.fromkeys(numbers))
	uniques.reverse()
	print(len(uniques))
	print(' '.join((str(x) for x in uniques)))
main()


n = int(input())
l = list(map(int, input().split()))
print(len(set(l)))
s = set(l)
for i in s:
	c = l.count(i)
	j = 0
	while j < len(l):
		if l[j] == i and c > 1:
			l.remove(i)
			c -= 1
		else:
			j += 1
print(*l)


n = int(input())
A = list(map(int, input().split()))
cnt = [0 for i in range(1001)]
for i in A:
	cnt[i] += 1
A = A[::-1]
B = []
for i in A:
	if cnt[i] >= 1:
		B.append(i)
		cnt[i] = 0
B = B[::-1]
print(len(B))
print(*B)


x = int(input())
y = [int(i) for i in input().split()]
z = []
for i in y[::-1]:
	if i not in z:
		z.append(i)
print(len(z))
for i in z[::-1]:
	print(i, end=' ')


n = int(input())
a = [int(i) for i in input().split()]
d = {}
b = []
c = 0
for i in range(n - 1, -1, -1):
	if a[i] not in d:
		d[a[i]] = i
		b.append(i)
		c += 1
print(c)
for ind in b[::-1]:
	print(a[ind], end=' ')


x = int(input())
l = list(map(int, input().split()))
p = len(set(l))
c = 0
i = 0
while len(l) != p:
	if l.count(l[i]) > 1:
		l.remove(l[i])
	else:
		i += 1
print(p)
for i in l:
	print(i, end=' ')


n = int(input())
a = list(map(int, input().split()))[::-1]
s = {a[0]}
ans = [str(a[0])]
for i in range(1, n):
	if a[i] not in s:
		s.add(a[i])
		ans.append(str(a[i]))
print(len(ans))
print(' '.join(ans[::-1]))


n = int(input())
l = input().split()
for i in range(len(l)):
	l[i] = int(l[i])
s = set(l)
for i in range(len(l) - 1, -1, -1):
	if l[i] in s:
		s.remove(l[i])
	else:
		l.remove(l[i])
print(len(l))
for i in range(len(l)):
	print(l[i], end=' ')


T_ON = 0
DEBUG_ON = 0
MOD = 998244353

def solve():
	n = read_int()
	A = read_ints()
	B = []
	vis = set()
	for i in reversed(range(n)):
		if A[i] not in vis:
			B.append(A[i])
		vis.add(A[i])
	B = B[::-1]
	print(len(B))
	print_nums(B)

def main():
	T = read_int() if T_ON else 1
	for i in range(T):
		solve()

def debug(*xargs):
	if DEBUG_ON:
		print(*xargs)
from collections import *
import math
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 read_int():
	return int(input())

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

def print_nums(nums):
	print(' '.join(map(str, nums)))

def YES():
	print('YES')

def Yes():
	print('Yes')

def NO():
	print('NO')

def No():
	print('No')

def First():
	print('First')

def Second():
	print('Second')

def fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	return a

def fib_ns(n):
	assert n >= 1
	f = [0 for _ in range(n + 1)]
	f[0] = 0
	f[1] = 1
	for i in range(2, n + 1):
		f[i] = f[i - 1] + f[i - 2]
	return f

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

def xgcd(a, b):
	(x0, x1, y0, y1) = (0, 1, 1, 0)
	while a != 0:
		((q, a), b) = (divmod(b, a), a)
		(y0, y1) = (y1, y0 - q * y1)
		(x0, x1) = (x1, x0 - q * x1)
	return (b, x0, y0)

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

def modinv(a, m):
	(g, x, _) = xgcd(a, m)
	if g != 1:
		raise Exception('gcd(a, m) != 1')
	return x % m

def mod_add(x, y):
	x += y
	while x >= MOD:
		x -= MOD
	while x < 0:
		x += MOD
	return x

def mod_mul(x, y):
	return x * y % MOD

def mod_pow(x, y):
	if y == 0:
		return 1
	if y % 2:
		return mod_mul(x, mod_pow(x, y - 1))
	p = mod_pow(x, y // 2)
	return mod_mul(p, p)

def mod_inv(y):
	return mod_pow(y, MOD - 2)

def mod_div(x, y):
	return mod_mul(x, mod_inv(y))

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

def gen_primes(n):
	P = [True for _ in range(n + 1)]
	P[0] = P[1] = False
	for i in range(int(n ** 0.5) + 1):
		if P[i]:
			for j in range(2 * i, n + 1, i):
				P[j] = False
	return P
main()


def int_lst_input():
	return [int(val) for val in input().split(' ')]

def int_input():
	return int(input())

def print_lst(lst):
	print(' '.join([str(val) for val in lst]))

def solve():
	n = int_input()
	a = int_lst_input()
	d = {}
	for (i, val) in enumerate(a):
		d[val] = i
	print(len(d))
	print_lst([a[i] for i in sorted(d.values())])
solve()


n = int(input())
a = list(input().split())
res = []
for i in a[::-1]:
	if i not in res:
		res.append(i)
result = ' '.join(res[::-1])
print(len(res))
print(result)


n = int(input())
a = [int(s) for s in input().split()]
a2 = set(a)
ans = []
a.reverse()
for i in a:
	if i not in ans:
		ans.append(i)
ans.reverse()
print(len(ans))
for elem in ans:
	print(elem, end=' ')


n = eval(input())
mkd = []
arr = input().split(' ')
arr2 = []
arr.reverse()
for x in arr:
	if x not in mkd:
		mkd = [x] + mkd
print(len(mkd))
for x in mkd:
	print(x, end=' ')


n = int(input())
a = input().split()
res = []
for i in reversed(a):
	if i not in res:
		res.append(i)
print(len(res))
print(' '.join(reversed(res)))


def compute(arr, n):
	fre = [False] * 1001
	index = n - 1
	while index >= 0:
		if fre[arr[index]] == False:
			fre[arr[index]] = True
		else:
			arr.pop(index)
		index -= 1
	print(len(arr))
	print(*arr)
n = int(input())
arr = list(map(int, input().split()))
compute(arr, n)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
mod = int(pow(10, 9) + 7)
mod2 = 998244353

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

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
n = l()[0]
A = l()
ans = []
s = set()
for i in range(n - 1, -1, -1):
	if A[i] not in s:
		ans = [A[i]] + ans
		s.add(A[i])
print(len(ans))
print(*ans)


n = int(input())
l = [int(i) for i in input().split()]
print(len(set(l)))
for i in range(len(l)):
	if l.count(l[i]) > 1:
		l[i] = ' '
for i in l:
	if i != ' ':
		print(i, end=' ')


x = int(input())
a = list(reversed(list(map(int, input().split()))))
m = []
for i in a:
	if i not in m:
		m.append(i)
print(len(m))
print(*list(reversed(m)))


n = int(input())
list1 = list(map(int, input().split()))
exist = [0] * 1001
ans = []
for i in range(n - 1, -1, -1):
	if not exist[list1[i]]:
		ans.append(list1[i])
		exist[list1[i]] = 1
	else:
		pass
ans.reverse()
print(len(ans))
print(*ans)


n = int(input())
a = list(map(int, input().split()))
s = set()
ans = []
for i in a[::-1]:
	if i in s:
		continue
	s.add(i)
	ans.append(i)
ans.reverse()
print(len(ans))
for i in ans:
	print(i, end=' ')


from collections import defaultdict
x = int(input())
A = [int(i) for i in input().split(' ')]
d = defaultdict(int)
B = []
for i in range(len(A) - 1, -1, -1):
	if d[A[i]] == 1:
		continue
	else:
		d[A[i]] += 1
		B.insert(0, A[i])
print(len(B))
print(*B)


n = int(input())
l = list(map(int, input().split()))
x = [j for (i, j) in enumerate(l) if j not in l[i + 1:]]
print(len(x))
print(*x)


a = int(input())
b = list(map(int, input().split()))
c = []
for i in range(a):
	if b[-i - 1] not in c:
		c.append(b[-i - 1])
c.reverse()
print(len(c))
print(*c, sep=' ')


x = int(input())
y = list(map(int, input().split()))
i = 0
while len(set(y)) != len(y):
	if y.count(y[i]) > 1:
		y.pop(i)
		continue
	i += 1
print(len(y))
print(*y, sep=' ')


n = int(input())
l = list(map(int, input().split()))
print(len(set(l)))
l.reverse()
temp = []
for i in range(n):
	if l[i] not in temp:
		temp.append(l[i])
mylen = len(set(l))
for i in range(mylen - 1, -1, -1):
	print(temp[i], end=' ')
print()


from collections import defaultdict

def main():
	n = int(input())
	a = list(map(int, input().split()))
	used = set()
	res = []
	for i in range(n - 1, -1, -1):
		if not a[i] in used:
			used.add(a[i])
			res.append(a[i])
	print(len(res))
	print(*reversed(res))
main()


input()
b = input().split()
i = 0
c = []
while i < len(b):
	if b[i] not in b[i + 1:]:
		c.append(b[i])
	i += 1
print(len(c))
print(' '.join(c))


n = int(input())
dados = input().split(' ')
aux = []
for i in range(n - 1, -1, -1):
	if dados[i] in aux:
		dados.remove(dados[i])
	else:
		aux.append(dados[i])
print(len(aux))
print(*dados)


n = int(input())
l = list(map(int, input().split()))
s = ''
d = {}
cnt = 0
for i in range(len(l) - 1, -1, -1):
	if l[i] not in d:
		s = str(l[i]) + ' ' + s
		d[l[i]] = i
		cnt += 1
print(cnt)
print(s)


n = int(input())
a = list(map(int, input().split()))[::-1]
lst = []
for i in a:
	if i not in lst:
		lst.append(i)
print(len(lst))
print(*lst[::-1])


def solve(n, a):
	arr = []
	for i in range(1, 1002):
		arr.append(False)
	while n >= 0:
		cur = a[n]
		if arr[cur] == True:
			a.pop(n)
		else:
			arr[cur] = True
		n -= 1
	print(len(a))
	for i in range(len(a)):
		print(a[i], end=' ')
n = int(input())
a = list(map(int, input().split()))
solve(n - 1, a)


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

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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

def main():
	n = int(input())
	a = list(map(int, input().split()))
	s = set()
	pos = [-1] * 1000
	for i in range(n):
		pos[a[i] - 1] = i
	ans = sorted([x for x in pos if x != -1])
	print(len(ans))
	print(' '.join([str(a[x]) for x in ans]))
main()


a = int(input())
b = list(map(int, input().split()))
c = len(b)
for i in range(len(b)):
	if b.count(b[i]) > 1:
		b[i] = 0
		c -= 1
print(c)
for i in range(len(b)):
	if b[i] != 0:
		print(b[i], end=' ')


def RemoveDups(ar, t):
	(output, i) = ([], t - 1)
	for i in ar[::-1]:
		if i not in output:
			output.append(i)
	print(len(output))
	for i in output[::-1]:
		print(i, end=' ')
t = int(input())
ar = list(map(int, input().split()))
RemoveDups(ar, t)


n = int(input())
arr = input().split(' ')
indices = [-1] * 1001
newIndices = []
newArr = []
for i in range(n):
	indices[int(arr[i])] = i
for i in range(len(indices)):
	if indices[i] != -1:
		newIndices.append(indices[i])
newIndices = sorted(newIndices)
for i in range(len(newIndices)):
	newArr.append(arr[newIndices[i]])
print(len(newArr))
print(' '.join(newArr))


x = int(input())
a = [int(i) for i in input().split()]
ans = []
for i in range(x - 1, -1, -1):
	if a[i] not in ans:
		ans.append(a[i])
print(len(ans))
print(*ans[::-1])


z = int(input())
x = [int(x) for x in input().split()]
y = []
x.reverse()
for i in x:
	if i not in y:
		y.append(i)
print(len(y))
y.reverse()
print(*y)


n = int(input())
a = [int(i) for i in input().split()]
x = []
for i in range(n, 0, -1):
	if a[i - 1] not in x:
		x.insert(0, a[i - 1])
print(len(x))
for j in x:
	print(j, end=' ')


n = int(input())
a = list(map(int, input().split()))
s = 0
l = []
for i in range(n):
	f = 0
	for j in range(i + 1, n):
		if a[i] == a[j]:
			f = 1
			break
	if f == 0:
		s = s + 1
		l.append(a[i])
print(s)
for i in range(s):
	print(l[i], end=' ')


def main():
	c = int(input())
	vals = [int(v) for v in input().split()]
	added = set()
	res = []
	for i in reversed(vals):
		if i not in added:
			res.append(i)
			added.add(i)
	print(len(res))
	print(' '.join(reversed([str(v) for v in res])))
main()


n = int(input())
s = list(map(int, input().split(' ')))
l = [0] * 1001
for i in range(n):
	l[s[i]] += 1
ans = []
for i in range(n):
	if l[s[i]] == 1:
		ans.append(s[i])
	l[s[i]] -= 1
print(len(ans))
for i in range(len(ans)):
	print(ans[i], end=' ')


n = int(input())
q = [int(x) for x in input().split()]
s = set()
ans = []
for i in range(n - 1, -1, -1):
	if q[i] not in s:
		t = q[i]
		s.add(t)
		ans.append(t)
print(len(ans))
print(' '.join(map(str, ans[::-1])))


n = int(input())
a = list(map(int, input().split()))
c = list(set(a))
d = []
for i in range(n - 1, -1, -1):
	if a[i] in c:
		d.append(a[i])
		del c[c.index(a[i])]
d = d[::-1]
print(len(d))
for i in d:
	print(i, end=' ')


numCount = int(input())
numList = [int(x) for x in input().split(' ')]
numDic = {}
for num in numList:
	numDic[num] = numDic.get(num, 0) + 1
ansList = []
for num in numList:
	if numDic[num] == 1:
		ansList.append(num)
	else:
		numDic[num] -= 1
print(len(ansList))
ansList = [str(x) for x in ansList]
ansString = ' '.join(ansList)
print(ansString)


n = int(input())
a = list(map(int, input().split()))
final = []
for i in a:
	if i in final:
		final.remove(i)
		final.append(i)
	else:
		final.append(i)
print(len(final))
print(*final)


n = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(n - 1, -1, -1):
	b = True
	for j in ans:
		if j == a[i]:
			b = False
	if b:
		ans.append(a[i])
print(len(ans))
for i in range(len(ans) - 1, -1, -1):
	print(ans[i], end=' ')


n = int(input())
a = [int(x) for x in input().split()]
b = []
c = set()
a = a[::-1]
for i in a:
	if i in c:
		continue
	else:
		c.add(i)
		b.append(i)
b = b[::-1]
print(len(b))
for k in b:
	print(k, end=' ')


n = int(input())
a = list(map(int, input().split()))
v = set()
ans = []
for x in reversed(a):
	if x not in v:
		v.add(x)
		ans.append(x)
print(len(ans))
print(' '.join(map(str, reversed(ans))))


n = int(input())
a = [int(x) for x in input().split()]
b = [0] * 1001
c = []
for i in range(n):
	b[a[i]] += 1
for i in range(n):
	if b[a[i]] > 1:
		b[a[i]] -= 1
	else:
		c.append(a[i])
print(len(c))
print(*c)


n = int(input())
ans = []
for x in list(map(int, input().split()))[::-1]:
	if x not in ans:
		ans.append(x)
print(len(ans))
print(*ans[::-1])


n = int(input())
arr = list(map(int, input().split()))
from collections import defaultdict
d = defaultdict(bool)
for i in range(len(arr) - 1, -1, -1):
	if d[arr[i]] == False:
		d[arr[i]] = True
	else:
		arr[i] = 0
arr = list(filter(lambda x: x != 0, arr))
print(len(arr))
print(*arr)


from collections import deque
t = int(input())
arr = list(map(int, input().split()))
temp = [0] * 1001
res = deque()
c = 0
for i in range(t - 1, -1, -1):
	if temp[arr[i]] == 0:
		temp[arr[i]] = 1
		res.appendleft(arr[i])
		c += 1
print(c)
print(*res)


n = int(input())
m = input().split()
lis = []
end = []
bla = False
for i in m[::-1]:
	for j in lis:
		if i == j:
			bla = True
	if bla == False:
		end.append(i)
	lis.append(i)
	bla = False
print(len(end))
for k in end[::-1]:
	print(k, end=' ')


n = int(input())
a = list(map(int, input().split()))
s = set()
for i in range(n - 1, -1, -1):
	if a[i] in s:
		a.pop(i)
	else:
		s.add(a[i])
print(len(a))
print(' '.join((str(num) for num in a)))


n = int(input())
ar = list(map(int, input().split()))
nfinal = []
ar = ar[::-1]
for i in ar:
	if i not in nfinal:
		nfinal.append(i)
print(len(nfinal))
nfinal.reverse()
print(*nfinal)


n = int(input())
p = input().rstrip().split(' ')
l = []
q = []
for i in range(len(p) - 1, -1, -1):
	if int(p[i]) not in l:
		q.append(int(p[i]))
		l.append(int(p[i]))
q.reverse()
print(len(q))
print(*q)


N = int(input())
L = list(map(int, input().split()))
L.reverse()
M = []
for a in L:
	if a not in M:
		M.append(a)
M.reverse()
print(len(M))
print(*M)


from collections import defaultdict

def solve(n, a):
	d = defaultdict(list)
	for (i, v) in enumerate(a):
		d[v].append(i)
	l = []
	for key in d.keys():
		l.append((d[key][-1], key))
	l.sort()
	print(len(l))
	l = map(lambda x: x[1], l)
	return ' '.join(map(str, l))

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


n = int(input())
integers = input().split(' ', n)
dictMap = {}
size = n
for i in range(n):
	if integers[i] not in dictMap:
		dictMap[integers[i]] = i
	else:
		integers[dictMap.get(integers[i])] = '$'
		dictMap.update({integers[i]: i})
		size -= 1
print(size)
for i in range(n):
	if integers[i] == '$':
		continue
	else:
		print(integers[i], end=' ')


n = int(input())
l = [int(i) for i in input().split(' ')]
res = []
l.reverse()
for i in l:
	if i not in res:
		res.append(i)
res.reverse()
print(len(res))
for (i, num) in enumerate(res):
	if i != 0:
		print(' ', end='')
	print(num, end='')
print()


i = int(input())
a = list(map(int, input().split()))
x = len(a)
for i in range(len(a)):
	for j in range(i + 1, len(a)):
		if a[i] == a[j]:
			a[i] = 0
			x -= 1
print(x)
for i in range(len(a)):
	if a[i] != 0:
		print(a[i], end=' ')


n = int(input())
M = []
S = set()
L = list(map(int, input().split()))
for i in range(n - 1, -1, -1):
	if L[i] not in S:
		S.add(L[i])
		M.append(L[i])
print(len(M))
M.reverse()
print(*M)


x = int(input())
arr = list(map(int, input().strip().split(' ')))
d = {}
for i in range(len(arr)):
	d[arr[i]] = 1
ans = [-1] * len(d)
k = len(ans) - 1
x = arr[::-1]
for i in range(len(x)):
	if x[i] in d and d[x[i]] is not 0:
		ans[k] = x[i]
		d[x[i]] = 0
		k -= 1
		if k is -1:
			break
print(len(ans))
if len(ans) is 0:
	print()
elif len(ans) is 1:
	print(ans[0])
else:
	for i in range(len(ans) - 1):
		print(ans[i], end=' ')
	print(ans[len(ans) - 1])


lastOccurence = [0] * 10000
n = int(input())
nb = list(map(int, input().split()))
for (indice, i) in enumerate(nb):
	lastOccurence[i] = indice
x = 0
a = []
for (indice, i) in enumerate(nb):
	if lastOccurence[i] == indice:
		x += 1
		a.append(i)
print(x)
print(*a)


n = int(input())
a = list(map(int, input().split()))
d = {}
lis = []
for i in a:
	if d.get(i):
		pass
	else:
		d[i] = 1
l = len(d)
while l > 0:
	if d[a[n - 1]]:
		lis.append(a[n - 1])
		d[a[n - 1]] = 0
		l -= 1
	n -= 1
lis.reverse()
print(len(d))
for i in lis:
	print(i, end=' ')


nItems = int(input())
items = map(int, input().split())
d = {}
for (index, it) in enumerate(items):
	d[it] = index
res = list(d.items())
res.sort(key=lambda e: e[1])
print(len(res))
print(*[v[0] for v in res])


n = input()
abc = list(map(int, input().split()))
abc.reverse()
new = []
for i in abc:
	if new.count(i) == 0:
		new.append(i)
print(len(new))
new.reverse()
for i in new:
	print(i, end=' ')


def sortFunc(e):
	return e[1]
mapa = {}
n = input()
numbers = [int(i) for i in input().split()]
for j in range(len(numbers)):
	if numbers[j] not in mapa.keys():
		mapa[numbers[j]] = [j]
	else:
		mapa[numbers[j]].append(j)
result = []
for i in mapa.keys():
	result.append([i, mapa[i][-1]])
result.sort(key=sortFunc)
s = ''
for l in result:
	if l != 0:
		s += str(l[0]) + ' '
print(len(mapa.keys()))
print(s.rstrip())


n = int(input())
nums = [int(j) for j in input().split()]
indices = 1000 * [-1]
for j in range(n):
	indices[nums[j] - 1] = j
(output, length) = ('', 0)
for j in range(n):
	if indices[nums[j] - 1] == j:
		output += str(nums[j]) + ' '
		length += 1
print(length)
print(output)


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

def ismember(x, arr):
	if x in arr:
		return True
	return False
arr2 = []
for i in range(len(arr) - 1, -1, -1):
	if ismember(arr[i], arr2):
		continue
	else:
		arr2.append(arr[i])
arr2 = arr2[::-1]
print(len(arr2))
for i in arr2:
	print(i, end=' ')


n = int(input())
lst = [int(x) for x in input().split()]
a = []
for x in range(n - 1, -1, -1):
	if not lst[x] in a:
		a.append(lst[x])
a.reverse()
print(len(a))
print(*a)


n = int(input())
numbers = list(map(int, input().split(' ')))[::-1]
num = set()
new_numbers = []
for i in numbers:
	if i not in num:
		new_numbers.append(i)
		num.add(i)
print(len(new_numbers))
print(*new_numbers[::-1])


n = int(input())
a = input().split(' ')
a = a[::-1]
s = []
for elem in a:
	if elem not in s:
		s.append(elem)
l = len(s)
print(l)
s = s[::-1]
print(' '.join(s))


n = int(input())
array_num = input().split(' ')
result = []
for x in range(len(array_num)):
	if array_num[-x - 1] not in result:
		result.append(array_num[-x - 1])
print(f"{len(result)}\n{' '.join(result[::-1])}")


n = int(input())
ar = list(map(int, input().split()))
s = set()
a = []
for x in ar[::-1]:
	if x not in s:
		a.append(x)
	s.add(x)
print(len(a))
print(*a[::-1])


n = int(input())
l = list(map(int, input().split()))
l = l[::-1]
d = []
c = 0
for i in l:
	if i not in d:
		d.append(i)
		c = c + 1
print(c)
print(*d[::-1])


n = int(input())
nums = list(map(int, input().split(' ')))
answer = []
for i in range(len(nums) - 1, -1, -1):
	if nums[i] not in answer:
		answer.append(nums[i])
answer.reverse()
print(len(answer))
print(*answer, sep=' ')


num = int(input())
arr = input().split(' ')
rs = []
i = 1
for x in arr:
	if x not in arr[i:]:
		rs.append(x)
	i += 1
print(len(rs))
print(' '.join(rs), end='')


from collections import OrderedDict
n = int(input())
l = list(map(int, input().split()))
l = l[::-1]
d = OrderedDict()
for i in l:
	d[i] = 1
l = len(d)
print(l)
for (k, v) in reversed(d.items()):
	print(k, end=' ')


import sys, math
from collections import defaultdict, deque, Counter
import itertools
mod = 10 ** 9 + 7
INF = float('inf')

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

def inpl():
	return list(map(int, sys.stdin.readline().split()))
n = inp()
a = inpl()
res = []
for i in range(n)[::-1]:
	if a[i] in res:
		continue
	res.append(a[i])
print(len(res))
print(*res[::-1])


n = int(input())
r = []
for i in list(map(int, input().split()))[::-1]:
	if not i in r:
		r.append(i)
print(len(r))
print(*r[::-1])


def contains(num, array):
	for i in array:
		if i == num:
			return True
	return False

def reverse(array):
	temp = []
	for i in range(len(array)):
		temp.append(array[len(array) - i - 1])
	return temp
num = input()
array = input().split(' ')
unique = []
array = reverse(array)
for i in array:
	if not contains(i, unique):
		unique.append(i)
print(len(unique))
unique = reverse(unique)
output = ''
for i in unique:
	output += i + ' '
print(output)


n = int(input())
a = [int(x) for x in input().split()]
res = []
for i in a[::-1]:
	if i not in res:
		res.append(i)
print(len(res))
print(*res[::-1])


a = [0] * 1001
n = int(input())
b = list(map(int, input().split()))
for i in range(n - 1, -1, -1):
	if b[i] in a:
		del b[i]
	else:
		a[b[i]] = b[i]
print(len(b))
for x in b:
	print(x, end=' ')


n = int(input())
l = list(map(int, input().split()))
n = n - 1
x = []
while n >= 0:
	if n == 0:
		if l[n] not in x:
			x.append(l[n])
	elif l[n] in l[:n - 1] and l[n] not in x:
		x.append(l[n])
	elif l[n] not in l[:n - 1] and l[n] not in x:
		x.append(l[n])
	n -= 1
x = x[::-1]
print(len(x))
print(*x, sep=' ')


n = int(input())
arr = list(map(int, input().split()))
dic = {}
for i in range(n):
	if arr[i] in dic:
		dic[arr[i]].append(i)
	else:
		dic[arr[i]] = [i]
print(len(dic))
out = []
for i in dic:
	out.append(dic[i][-1])
out.sort()
for i in out:
	print(arr[i], end=' ')
print()


n = int(input())
lst = list(map(int, input().split(' ')))
out = []
for i in lst.__reversed__():
	if i in out:
		continue
	else:
		out.insert(0, i)
print(len(out))
s = ''
for i in out:
	s += str(i) + ' '
print(s)


def solve():
	input()
	ls = list(map(int, input().split()))
	ans = []
	for x in ls[::-1]:
		if x not in ans:
			ans = [x] + ans
	print(len(ans))
	print(*ans)
solve()


size = int(input())
array = input().split()
index = 0
while index < len(array):
	if array[index] in array[index + 1:len(array)]:
		array.pop(index)
	else:
		index += 1
print(len(array))
string = ''
for j in range(0, len(array)):
	string += str(array[j]) + ' '
print(string)


from __future__ import division, print_function
import bisect
import math
import heapq
import itertools
import sys
from collections import deque
from atexit import register
from collections import Counter
from functools import reduce
if sys.version_info[0] < 3:
	from io import BytesIO as stream
else:
	from io import StringIO as stream
if sys.version_info[0] < 3:

	class dict(dict):

		def items(self):
			return dict.iteritems(self)

		def keys(self):
			return dict.iterkeys(self)

		def values(self):
			return dict.itervalues(self)
	input = raw_input
	range = xrange
	filter = itertools.ifilter
	map = itertools.imap
	zip = itertools.izip

def sync_with_stdio(sync=True):
	global input, flush
	if sync:
		flush = sys.stdout.flush
	else:
		sys.stdin = stream(sys.stdin.read())
		input = lambda : sys.stdin.readline().rstrip('\r\n')
		sys.stdout = stream()
		register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))

def main():
	n = int(input())
	a = [int(o) for o in input().split()]
	s = set()
	ans = []
	for i in a[::-1]:
		if i not in s:
			ans.append(i)
			s.add(i)
	print(len(ans))
	print(*ans[::-1])
sync_with_stdio(False)
main()


n = int(input())
a = list(map(int, input().split()))
res = []
seen = set()
for e in reversed(a):
	if e in seen:
		continue
	res.append(e)
	seen.add(e)
print(len(res))
print(' '.join((str(x) for x in reversed(res))))


n = int(input())
lst = list(map(int, input().split()))
ans = []
lst = lst[::-1]
for i in lst:
	if i not in ans:
		ans.append(i)
ans = ans[::-1]
print(len(ans))
for i in ans:
	print(i, end=' ')


import sys
n = int(input())
lista = [int(x) for x in input().strip().split()]
sta = list(reversed(lista[:]))
visited = [0 for i in range(1001)]
oper = []
for i in range(0, len(sta)):
	if visited[sta[i]] == 0:
		visited[sta[i]] = 1
		oper.append(sta[i])
print(len(oper))
for i in range(0, len(oper)):
	print(oper[len(oper) - i - 1], end=' ')


def main():
	input()
	arr = reversed(list(map(int, input().split())))
	s = set()
	res = list()
	for item in arr:
		if item not in s:
			res.append(item)
			s.add(item)
	print(len(res))
	print(' '.join([str(x) for x in reversed(res)]))
main()


n = int(input())
l = list(map(int, input().split()))
s = set()
new = []
for i in range(n - 1, -1, -1):
	x = l[i]
	if x not in s:
		s.add(l[i])
		new.append(l[i])
y = len(new)
print(y)
for i in range(y - 1, -1, -1):
	print(new[i], end=' ')
print()


n = int(input())
ns = list(map(int, input().split()))[::-1]
fs = []
for x in ns:
	if x not in fs:
		fs.append(x)
print(len(fs))
print(*fs[::-1])


t = input()
a = list(map(int, input().split()))
non_repeat = []
for i in a[-1::-1]:
	if i not in non_repeat:
		non_repeat.append(i)
print(len(non_repeat))
for i in non_repeat[-1::-1]:
	print(i, end=' ')


x = int(input())
io = list(map(int, input().split()))
i = 0
while i < len(io) and len(io) != 1:
	if io[i] in io[i + 1:]:
		io.pop(i)
	else:
		i += 1
print(len(io))
for k in io:
	print(k, end=' ')


x = int(input())
s = list(map(str, input().split()))
l = len(s)
p = []
c = 0
pp = ''
for n in range(l - 1, -1, -1):
	if s[n] not in p:
		c = c + 1
		p.append(s[n])
p = p[::-1]
for n in range(len(p)):
	pp = pp + p[n] + ' '
print(c)
print(pp)


n = int(input())
arr = list(map(int, input().split()))
arr2 = [e for (i, e) in enumerate(arr) if e not in arr[i + 1:]]
print(len(arr2))
print(' '.join((str(e) for e in arr2)))


import sys
n = int(sys.stdin.readline())
nums = list(map(int, sys.stdin.readline().strip().split()))
printed = [False] * 1001
result = []
for i in range(n):
	if not printed[nums[n - i - 1]]:
		printed[nums[n - i - 1]] = True
		result.append(nums[n - i - 1])
print(len(result))
print(' '.join(map(str, reversed(result))))


n = int(input())
a = list(reversed(list(map(int, input().split()))))
for i in range(len(a)):
	st = a[i]
	for j in range(len(a)):
		try:
			if a[j] == st:
				a[j] = -1
		except:
			pass
	a[i] = st
while -1 in a:
	a.remove(-1)
b = list(reversed(a))
strs = ''
for i in range(len(b)):
	if i != len(b) - 1:
		strs = strs + str(b[i]) + ' '
	else:
		strs = strs + str(b[i])
print(len(b))
print(strs)


import sys
input = sys.stdin.readline

def solve(n, arr):
	freq = [0] * (1000 + 1)
	for num in arr:
		freq[num] += 1
	res = []
	for num in arr:
		freq[num] -= 1
		if freq[num] == 0:
			res.append(num)
	return res
n = int(input())
arr = list(map(int, input().split()))
arr = solve(n, arr)
print(len(arr))
print(*arr)


n = int(input())
string = input().split(' ')
result = []
for i in range(n - 1, -1, -1):
	if string[i] not in result:
		result.insert(0, string[i])
print(len(result))
print(' '.join(result))


n = int(input())
seq = input().split()
rep = []
for i in seq:
	if i not in rep:
		rep.append(i)
	else:
		rep.remove(i)
		rep.append(i)
print(len(rep))
for j in rep:
	if rep.index(j) == len(rep) - 1:
		print(j)
	else:
		print(j, end=' ')


l = input()
ab = input().split()
test = []
ab.reverse()
for i in ab:
	if i not in test:
		test.append(i)
print(len(test))
test.reverse()
for i in test:
	print(int(i), end=' ')


n = int(input())
a = list(map(int, input().split()))
r = []
c = 0
for i in a:
	if i not in r:
		r.append(i)
	else:
		c += 1
res = []
while a:
	if a.count(a[0]) == 1:
		res.append(a[0])
	a = a[1:]
print(len(r))
print(' '.join(map(str, res)))


n = int(input())
l = input().split()
l.reverse()
ans = []
while len(l) > 0:
	ans.append(l[0])
	k = 1
	while k < len(l):
		if l[k] == l[0]:
			l.pop(k)
			k = k - 1
		k = k + 1
	l.pop(0)
ans.reverse()
print(len(ans))
ansStr = ''
for elem in ans:
	ansStr = ansStr + elem + ' '
print(ansStr[0:len(ansStr) - 1])


n = int(input())
a = list(map(int, input().split()))
a.reverse()
s = set()
ans = []
for el in a:
	if el not in s:
		s.add(el)
		ans.append(el)
ans.reverse()
print(len(s))
for el in ans:
	print(el, end=' ')


(n, arr, ans) = (int(input()), input().split(), [])
for a in arr:
	if a in ans:
		ans.remove(a)
	ans.append(a)
print(len(ans))
print(*ans)


n = int(input())
lis = list(map(int, input().split()))
has = [0] * 100000
ans = []
for i in range(n - 1, -1, -1):
	if has[lis[i]] == 0:
		ans.append(lis[i])
		has[lis[i]] = 1
print(len(ans))
print(*ans[::-1])


from sys import stdin
from collections import deque
input = stdin.readline
n = int(input())
a = [int(x) for x in input().split()]
s = set()
ans = deque()
for i in range(n - 1, -1, -1):
	if a[i] in s:
		continue
	s.add(a[i])
	ans.appendleft(a[i])
print(len(ans))
print(*ans)


n = int(input())
a = list(map(int, input().split()))
a = a[::-1]
rec = []
for i in range(n):
	if a[i] not in rec:
		rec.append(a[i])
print(len(rec))
print(' '.join(map(str, rec[::-1])))


n = int(input())
l = list(map(int, input().split()))
rdup = []
l = l[::-1]
for i in l:
	if i not in rdup:
		rdup.append(i)
rdup = rdup[::-1]
print(len(rdup))
for i in rdup:
	print(i, end=' ')


n = int(input())
pop = list(map(int, input().split()))
po = set(pop)
for item in po:
	kam = pop.count(item)
	for x in range(kam - 1):
		pop.remove(item)
print(len(pop))
print(*pop)


x = int(input())
inp = input().split()
li1 = list(inp)
li1.reverse()
li2 = [-1] * 1000000
li3 = []
for i in li1:
	if li2[int(i)] == -1:
		li2[int(i)] = 1
		li3.append(str(i))
print(len(li3))
out = ' '.join((i for i in li3[::-1]))
print(out)


n = int(input())
a = [int(x) for x in input().split()]
answer = []
for i in range(len(a) - 1, -1, -1):
	nxt = a[i]
	if not nxt in answer:
		answer.insert(0, nxt)
print(len(answer))
for x in answer:
	print(str(x), end=' ')


n = int(input())
l = list(map(int, input().split()))
a = []
for i in range(n):
	if l[i] in a:
		a.pop(a.index(l[i]))
		a.append(l[i])
	else:
		a.append(l[i])
print(len(a))
print(*a)


n = int(input())
a = list(map(str, input().split()))
existe = set()
for i in range(n - 1, -1, -1):
	if a[i] not in existe:
		existe.add(a[i])
	else:
		a.remove(a[i])
print(len(a))
print(' '.join(a))


(n, a) = (int(input()), list(map(int, input().split())))
v = [str(ai) for (i, ai) in enumerate(a) if ai not in a[i + 1:]]
print(len(v), ' '.join(v), sep='\n')


n = int(input())
l = input().split()
l = [int(i) for i in l]
nl = []
for i in reversed(l):
	if i not in nl:
		nl.append(i)
print(len(nl))
for i in reversed(nl):
	print(i, end=' ')


n = int(input())
a = list(map(int, input().split()))
c = []
for i in range(0, len(a)):
	if a[i] not in a[i + 1:len(a)]:
		c.append(a[i])
print(len(c))
for item in c:
	print(item, end=' ')


def print_array(array):
	array = ' '.join(array)
	print(array)
num_el = int(input())
arr = input().split()
unique = set()
for i in range(len(arr) - 1, -1, -1):
	if arr[i] in unique:
		arr.pop(i)
	else:
		unique.add(arr[i])
print(len(arr))
print_array(arr)


n = int(input())
arr = list(map(int, input().split()))
indexOfPrevious = [-1] * 1005
remove = arr
count = 0
for i in range(len(arr)):
	if indexOfPrevious[arr[i]] != -1:
		remove[indexOfPrevious[arr[i]]] = -1
		n -= 1
	indexOfPrevious[arr[i]] = i
print(n)
for i in remove:
	if i != -1:
		print(i, end=' ')


input()
a = [int(x) for x in input().split()]
a.reverse()
b = []
for x in a:
	if (x in b) == False:
		b.append(x)
print(len(b))
b.reverse()
for x in b:
	print(str(x) + ' ', end='')


n = int(input())
nums = list(map(int, input().split(' ')))
counts = [0 for _ in range(1001)]
for i in range(n - 1, -1, -1):
	if counts[nums[i]] <= 0:
		counts[nums[i]] += 1
	else:
		nums.pop(i)
print(len(nums))
print(' '.join([str(x) for x in nums]))


from sys import stdin, stdout
import math
N = int(input())
arr = [int(x) for x in stdin.readline().split()]
arr = arr[::-1]
freq = {}
k = 0
for num in arr:
	if num not in freq:
		k += 1
	freq[num] = 1
print(k)
ans = [0] * k
i = 0
for key in freq:
	ans[i] = key
	i += 1
ans = ans[::-1]
print(*ans)


n = int(input())
l = list(map(int, input().split()))
a = list(set(l))
for i in range(len(a)):
	z = l.count(a[i])
	if z > 1:
		for j in range(z - 1):
			l.remove(a[i])
print(len(l))
print(*l)


n = int(input())
a = list(map(int, input().split()))
x = [[0, 0]] * 1001
for i in range(n):
	x[a[i]] = [i, a[i]]
answer = []
for i in range(1, 1001):
	if x[i][1] > 0:
		answer.append(x[i])
answer = sorted(answer, key=lambda x: x[0])
print(len(answer))
for x in answer:
	print(x[1], end=' ')


def main():
	n = int(input())
	line = [int(i) for i in input().split()]
	repeat = set()
	ans = []
	for i in range(n - 1, -1, -1):
		if not line[i] in repeat:
			repeat.add(line[i])
			ans.append(line[i])
	print(len(ans))
	ans.reverse()
	print(' '.join([str(i) for i in ans]))
main()


n = int(input())
ns = list(map(int, input().split()))
nss = []
for num in reversed(ns):
	if num not in nss:
		nss.append(num)
print(len(nss))
print(' '.join(list(map(str, reversed(nss)))))


n1 = int(input())
lis = input().split(' ')
lis2 = []
for i in range(len(lis)):
	lis[i] = int(lis[i])
for j in range(len(lis)):
	if lis[j] not in lis2:
		lis2.append(lis[j])
	else:
		lis2.remove(lis[j])
		lis2.append(lis[j])
print(len(lis2))
print(*lis2)


n = int(input())
a = list(map(int, input().split()))
d = {}
for x in range(n):
	d[a[x]] = x
print(len(d))
for x in range(n):
	if d[a[x]] == x:
		print(a[x], end=' ')


m = int(input())
n = list(map(int, input().split()))
n.reverse()
s = []
if len(n) == 1:
	s.append(n[0])
else:
	for i in range(len(n)):
		if n[i] not in s:
			s.insert(0, n[i])
print(len(s))
print(' '.join(map(str, s)))


a = int(input())
b = list(map(int, input().split()))
b = list(reversed(b))
c = []
for x in b:
	if x not in c:
		c.append(x)
print(len(c))
print(*reversed(c))


a = int(input())
b = list(map(int, input().split()))
z = list(b)
z.reverse()
k = []
m = list(set(z))
print(len(set(b)))
for x in range(len(set(b))):
	k.append(len(b) - z.index(m[x]) - 1)
k.sort()
for x in k:
	print(b[x], end=' ')


_ = input()
l = input().split()
res = []
for i in range(len(l)):
	if l[i:].count(l[i]) == 1:
		res.append(l[i])
print(len(res))
print(' '.join(res))


n = int(input())
a = list(map(int, input().split()))
res = []
s = set()
for i in range(n - 1, -1, -1):
	if a[i] not in s:
		res = [str(a[i])] + res
		s.add(a[i])
print(len(res))
print(' '.join(res))


n = int(input())
l = list(map(int, input().split()))
m = set(l)
print(len(m))
ans = []
for i in l[::-1]:
	if i in m:
		ans.append(i)
		m.remove(i)
print(*ans[::-1])


n = int(input())
x = [int(i) for i in input().split()][::-1]
y = set()
yy = []
for i in x:
	if i not in y:
		y.add(i)
		yy.append(i)
yy = yy[::-1]
print(len(yy))
for i in yy:
	print(i, end=' ')


input()
s = []
for x in list(input().split())[::-1]:
	if not x in s:
		s.append(x)
print(len(s))
print(*s[::-1])


n = int(input())
p = input().rstrip().split(' ')
p.reverse()
l = []
for i in range(0, len(p)):
	if p[i] not in l:
		l.append(p[i])
print(len(l))
l.reverse()
C = ' '.join(l)
print(C)


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

def outline(l):
	print(' '.join([str(i) for i in l]))
n = int(input())
lst = inline()
found = list()
count = 0
for i in range(len(lst) - 1, -1, -1):
	if lst[i] not in found:
		found.append(lst[i])
		count += 1
print(count)
outline(list(reversed(found)))


n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n - 1, -1, -1):
	if a[i] not in b:
		b.append(a[i])
	else:
		pass
print(len(b))
print(*b[::-1])


n = int(input())
a = input().split()
l = []
c = 0
for i in range(1, n + 1):
	if a[-i] not in l:
		l.insert(0, a[-i])
		c += 1
print(c)
makeitastring = ' '.join(map(str, l))
print(makeitastring)


N = int(input())
L1 = list(map(int, input().split()))
D = dict()
L2 = []
for i in range(N - 1, -1, -1):
	if L1[i] not in D:
		D[L1[i]] = i
		L2.append(L1[i])
print(len(L2))
for i in range(len(L2) - 1, -1, -1):
	print(L2[i], end=' ')


from collections import OrderedDict
n = input()
n = int(n)
lista = []
arr = map(int, input().split())
lista = list(map(int, arr))
lista = lista[::-1]
lista = list(OrderedDict.fromkeys(lista))
lista = lista[::-1]
print(len(lista))
print(str(' '.join((str(x) for x in lista))))


def solve(ele):
	dic = {}
	for i in ele:
		if i in dic:
			dic[i] += 1
		else:
			dic[i] = 1
	result = []
	for i in ele:
		if dic[i] == 1:
			result.append(str(i))
		else:
			dic[i] -= 1
	return (len(result), ' '.join(result))
n = input()
elements = list(map(int, input().split()))
(size, result) = solve(elements)
print(size)
print(result)


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

def print_arr(arr):
	print(*arr, sep=' ')
n = int(input())
a = arr_inp()
unique = []
for i in range(n - 1, -1, -1):
	if a[i] not in unique:
		unique.insert(0, a[i])
print(len(unique))
print_arr(unique)


import os
import sys
n = int(input())
a = input().split()
l = len(a) - 1
f = []
while l >= 0:
	if a[l] not in f and a[l] != ' ':
		f.append(a[l])
	l -= 1
k = len(f) - 1
r = ''
while k >= 0:
	if k != 0:
		r += str(f[k]) + ' '
	else:
		r += str(f[k])
	k -= 1
print(len(f))
print(r)


n = int(input())
l = [int(i) for i in input().split()]
c = [0 for i in range(1000 + 1)]
k = []
for e in l[::-1]:
	if c[e] == 0:
		k.append(e)
		c[e] = 1
print(len(k))
for e in k[::-1]:
	print(e, end=' ')
print()


n = int(input())
l1 = []
l = list(map(int, input().split(' ')))
for i in range(n - 1, -1, -1):
	l1.append(l[i])
	l.remove(l[i])
l1 = list(reversed(l1))
l1.append('NONE')
print(len(set(l1)) - 1)
for i in range(0, n):
	if l1[i] != l1[i + 1]:
		print(l1[i], end=' ')


N = int(input())
A = list(map(int, input().strip().split()))
di = {}
for i in range(N):
	di[A[i]] = i
C = []
for (k, v) in di.items():
	C.append([v, k])
C.sort(key=lambda x: x[0])
l = len(C)
print(l)
for i in range(l):
	if i != l - 1:
		print(C[i][1], end=' ')
	else:
		print(C[i][1])


import sys
data = sys.stdin.readlines()
lis = []
for line in data:
	lis.append(line)
n = int(lis[0])
seq = list(map(int, lis[1].split()))
elments = set([])
unique = []
for i in range(1, len(seq) + 1):
	elm = seq[-i]
	if elm in unique:
		pass
	else:
		unique.insert(0, elm)
print(len(unique))
for elm in unique:
	print(elm, end=' ')


n = int(input())
li = list(map(int, input().split()))
size = n
for i in range(n):
	for j in range(i):
		if li[j] == li[i]:
			li[j] = 0
			size -= 1
print(size)
for i in li:
	if i != 0:
		print(i, end=' ')


x = int(input())
l = list(map(int, input().split()))
b = []
for i in l[::-1]:
	if i not in b:
		b.append(i)
print(len(b))
print(*b[::-1])


n = input()
a = input().split(' ')[::-1]
s = set()
ans = []
for v in a:
	if v not in s:
		ans.append(v)
		s.add(v)
print(len(ans))
print(' '.join(ans[::-1]))


n = int(input())
seen = []
A = input().split(' ')
for num in A:
	num = int(num)
for i in range(len(A)):
	if A[len(A) - i - 1] not in seen:
		seen.append(A[len(A) - i - 1])
print(len(seen))
for num in seen[::-1]:
	print(num, end=' ')


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

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

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

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

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

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

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

def S():
	return input()

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

def main():
	n = I()
	a = LI()
	r = []
	s = set()
	for c in a[::-1]:
		if c in s:
			continue
		s.add(c)
		r.append(c)
	return '{}\n{}'.format(len(r), ' '.join(map(str, r[::-1])))
print(main())


s = int(input())
a = list(map(int, input().split()))
a.reverse()
r = 0
t = []
while len(a) != 0:
	r += 1
	q = a[0]
	t.append(q)
	del a[0]
	while q in a:
		del a[a.index(q)]
print(r)
t.reverse()
for i in range(r - 1):
	print(t[i], end=' ')
print(t[-1])


n = int(input())
l = list(map(int, input().split()))
x = []
for j in range(len(l) - 1, -1, -1):
	if l[j] not in x:
		x.append(l[j])
print(len(x))
x.reverse()
print(*x)


def Reverse(lst):
	return [ele for ele in reversed(lst)]

def unique(list1):
	unique_list = []
	lst = []
	for x in list1:
		if x not in unique_list:
			unique_list.append(x)
	for x in unique_list:
		lst += [x]
	return lst
n = int(input())
dum = str(input())
s = dum.split()
dum = []
for i in s:
	i = int(i)
	dum.append(i)
dum1 = Reverse(dum)
dum2 = unique(dum1)
ans1 = len(dum2)
ans = Reverse(dum2)
print(ans1)
for i in ans:
	print(i, end=' ')


input()
a = list(map(int, input().split()))
a = list(reversed(a))
b = []
for i in a:
	if i not in b:
		b.append(i)
print(len(b))
print(*reversed(b))


n = int(input())
a = list(map(int, input().strip().split()))
a.reverse()
c = list()
for i in range(n):
	if a[i] in c:
		a[i] = 0
	else:
		c.append(a[i])
a.reverse()
l = list(filter(lambda x: x > 0, a))
print(len(l))
print(' '.join(map(str, l)))


n = int(input())
x = list(map(int, input().split()))[::-1]
for i in range(n - 1, -1, -1):
	a = x[i]
	x[i] = ''
	if a not in x:
		x[i] = a
x = list(filter(''.__ne__, x))[::-1]
print(len(x))
print(*x)


n = int(input())
arr = [int(x) for x in input().split()]
d = {}
x = []
for i in range(n - 1, -1, -1):
	if arr[i] not in d:
		d[arr[i]] = 1
		x.append(arr[i])
	else:
		continue
print(len(x))
for i in range(len(x) - 1, -1, -1):
	print(x[i], end=' ')


n = int(input())
a = [int(x) for x in input().split(' ')]
(mark, rem) = ([], [])
for i in range(1001):
	mark.append(False)
for elem in a[::-1]:
	if not mark[elem]:
		mark[elem] = True
		rem.append(elem)
print(len(rem))
for elem in rem[::-1]:
	print(elem, end=' ')


n = int(input())
L = list(map(int, input().split()))
L1 = [True] * 1001
L2 = []
for k in L[::-1]:
	if L1[k]:
		L2.append(str(k))
		L1[k] = False
print(len(L2))
print(' '.join(L2[::-1]))


z = int(input())
x = list(map(int, input().split()))
c = []
for i in reversed(x):
	if i not in c:
		c.append(i)
print(len(c))
for i in reversed(c):
	print(i, end=' ')


def f(l):
	llen = len(l)
	d = {}
	for n in l:
		if n in d:
			d[n] += 1
		else:
			d[n] = 1
	for i in range(llen):
		if d[l[i]] > 1:
			d[l[i]] -= 1
			l[i] = 'a'
	while 'a' in l:
		l.remove('a')
	print(len(l))
	return ' '.join(map(str, l))
num_lems = int(input())
elems = [int(n) for n in input().split()]
print(f(elems))


from collections import OrderedDict
n = int(input())
l = list(map(int, reversed(input().split())))
l = list(reversed(OrderedDict.fromkeys(l).keys()))
print(len(l))
print(*l)


n = int(input())
l = list(map(int, input().split(' ')))
l.reverse()
s = []
for i in range(n):
	if not l[i] in s:
		s.append(l[i])
s.reverse()
print(len(s))
print(*s)


n = int(input())
arr = list(map(int, input().split()))
aux = []
for i in range(n - 1, -1, -1):
	if arr[i] not in aux:
		aux.append(arr[i])
string = ''
space = False
for j in range(len(aux) - 1, -1, -1):
	if space:
		string += ' '
	string += str(aux[j])
	space = True
print(len(aux))
print(string)


def removeDouble(a_list):
	for i in a_list:
		if a_list.count(i) > 1:
			a_list.remove(i)
			break
	else:
		return a_list
	return removeDouble(a_list)
n = int(input())
num = [int(i) for i in input().strip().split(' ')]
num = removeDouble(num)
print(len(num))
print(' '.join([str(i) for i in num]))


n = int(input())
a = [int(i) for i in input().split()]
b = set(a)
pos = 0
poss = []
print(len(b))
for i in b:
	for j in range(n):
		if i == a[j]:
			pos = j
	poss.append(pos)
poss.sort()
for i in poss:
	print(a[i], end=' ')


n = int(input())
c = input()
a = c.split()
a.reverse()
b = []
for i in range(0, n):
	if a[i] in a and a[i] not in b:
		b.append(a[i])
b.reverse()
print(len(b))
for i in b:
	print(i, end=' ')
	if i == len(b):
		print()


n = int(input())
ls = list(map(int, input().split()))
res = []
ls = ls[::-1]
d = {}
for i in ls:
	d[i] = False
for i in ls:
	if d[i] == False:
		d[i] = True
		res.append(i)
print(len(res))
for i in res[::-1]:
	print(i, end=' ')
print()


n = int(input())
l = list(map(int, input().split()))
k = []
for i in l:
	if i in k:
		k.remove(i)
		k.append(i)
	else:
		k.append(i)
print(len(k))
print(*k)


def NaytiChisla(stroka):
	kek = ''
	chislo = []
	koef = 1
	for i in range(len(stroka)):
		if stroka[i] == '-':
			koef = -1
		if stroka[i] == '0' or stroka[i] == '1' or stroka[i] == '2' or (stroka[i] == '3') or (stroka[i] == '4') or (stroka[i] == '5') or (stroka[i] == '6') or (stroka[i] == '7') or (stroka[i] == '8') or (stroka[i] == '9'):
			kek += stroka[i]
		if stroka[i] == ' ':
			chislo.append(int(kek) * koef)
			koef = 1
			kek = ''
	chislo.append(int(kek) * koef)
	koef = 1
	return chislo
n = int(input())
mas = NaytiChisla(str(input()))
m = []
mas = mas[::-1]
for i in mas:
	if i not in m:
		m.append(i)
print(len(m))
stroka = ''
m = m[::-1]
for i in m:
	stroka += str(i)
	stroka += ' '
stroka = stroka[::1]
print(stroka)


def rev_list(l):
	rev = []
	for i in range(len(l) - 1, -1, -1):
		rev.append(l[i])
	return rev
n = int(input())
l = list(map(int, input().split()))
d = []
for i in range(len(l) - 1, -1, -1):
	if l[i] in d:
		pass
	else:
		d.append(l[i])
print(len(d))
print(' '.join((str(i) for i in rev_list(d))))


t = int(input())
l = [int(i) for i in input().split()]
l.reverse()
d = {}
for i in l:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
k = list(d.keys())
k.reverse()
print(len(k))
for i in k:
	print(i, end=' ')


num = int(input())
arr = list(map(int, input().split()))
lst = []
while len(arr) != 0:
	x = arr.pop()
	if x not in lst:
		lst.append(x)
print(len(lst))
print(*lst[::-1])


n = int(input())
inp = input()
arr = inp.split(' ')
arr2 = []
for i in range(n):
	if not arr[i] in arr2:
		arr2.append(arr[i])
	else:
		arr2.remove(arr[i])
		arr2.append(arr[i])
print(len(arr2))
for i in range(len(arr2)):
	print(arr2[i], end=' ')


input()
arr = input().strip().split(' ')
dup = set()
ans = []
for elem in arr[::-1]:
	if not elem in dup:
		dup.add(elem)
		ans.append(elem)
print(len(ans))
for elem in ans[::-1]:
	print(elem, end=' ')


n = int(input())
a = [int(i) for i in input().split()]
a.reverse()
result = []
for i in range(0, len(a)):
	if a[i] not in result:
		result.append(a[i])
print(len(result))
result.reverse()
for i in range(0, len(result)):
	print(result[i], end=' ')


from math import log
n = int(input())
ai = list(map(int, input().split()))
s = set()
for i in range(n):
	s.add(ai[i])
num = n
for i in range(n - 1, -1, -1):
	if ai[i] not in s:
		ai[i] = -1
		num -= 1
	else:
		s.remove(ai[i])
print(num)
for i in range(n):
	if ai[i] != -1:
		print(ai[i], end=' ')


n = int(input())
D = set()
rresult = []
for x in [int(x) for x in input().split()][::-1]:
	if x not in D:
		rresult += [x]
		D.add(x)
print(len(rresult))
print(' '.join(map(str, rresult[::-1])))


n = int(input())
a = list(map(int, input().split()))
nums = set()
ans = []
for i in range(n - 1, -1, -1):
	if a[i] not in nums:
		nums.add(a[i])
		ans.append(a[i])
print(len(ans))
for i in range(len(ans) - 1, -1, -1):
	print(ans[i], end=' ')


import sys
import bisect
import math as mt
input = sys.stdin.readline
t = 1
mod = 10 ** 9 + 7
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in range(n):
		if d.get(l[i], -1) == -1:
			d[l[i]] = []
		d[l[i]].append(i)
	l1 = [0] * n
	for i in d:
		l1[d[i][-1]] = i
	print(len(d))
	for i in range(n):
		if l1[i] != 0:
			print(l1[i], end=' ')
	print()


N = int(input())
nums = list(map(int, input().split()))
nums = nums[::-1]
li_uniq = []
for x in nums:
	if x not in li_uniq:
		li_uniq.append(x)
print(len(li_uniq))
ans = map(str, li_uniq[::-1])
print(' '.join(ans))


N = int(input())
li = list(map(int, input().split()))
for k in range(min(li), max(li) + 1):
	indexes = [i for (i, x) in enumerate(li) if x == k]
	if len(indexes) == 2:
		li.remove(k)
	elif len(indexes) > 2:
		for l in range(len(indexes) - 1):
			li.remove(k)
	else:
		pass
print(len(li))
print(' '.join(map(str, li)))


n = int(input())
t = list(map(int, input().split()))
t.reverse()
ls = [t[0]]
for i in range(1, n):
	if t[i] in ls:
		continue
	else:
		ls.append(t[i])
print(len(ls))
ls.reverse()
print(*ls)


a = input()
total = [int(x) for x in input().split()]
dict1 = {}
dict2 = {}
ans = []
for i in total:
	if i not in dict1:
		dict1[i] = total.count(i)
		dict2[i] = 1
for i in total:
	if dict2[i] == dict1[i]:
		ans.append(i)
	else:
		dict2[i] += 1
print(len(ans))
ans1 = ''
for i in ans:
	ans1 += str(i) + ' '
ans1 = ans1[:-1]
print(ans1)


n = input()
l = list(map(int, input().split()))
s = set(l)
print(len(s))
l2 = list(l)
for i in l:
	if l2.count(i) == 1:
		print(i, end=' ')
	else:
		l2.remove(i)


n = int(input())
arr = list(input().split())
arr.reverse()
ret = []
for i in range(n):
	if arr[i] not in ret:
		ret.append(arr[i])
ret.reverse()
print(len(ret))
print(' '.join(ret))


a = input('')
b = []
b = input().split(' ')
c = len(set(b))
d = []
print(c)
for i in range(len(b), 0, -1):
	if b[i - 1] not in d:
		d.append(b[i - 1])
for j in reversed(d):
	print(j, end=' ')


n = int(input())
a = list(map(int, input().strip().split()))[:n]
b = []
count = 0
for i in a:
	if i not in b:
		b.append(i)
for i in b:
	while a.count(i) != 1:
		a.remove(i)
for i in a:
	count = count + 1
print(count)
for i in a:
	print(i, end=' ')


def Remove_Duplicates(arr):
	res = []
	count = 0
	for i in arr[::-1]:
		if i not in res:
			res.append(i)
			count += 1
	print(count)
	print(*res[::-1])
n = int(input())
arr = list(map(int, input().split()))
Remove_Duplicates(arr)


n = int(input())
m = list(map(int, input().split()))
s = set()
res = []
for k in reversed(m):
	if k not in s:
		s.add(k)
		res.append(k)
res = list(reversed(res))
print(len(res))
print(' '.join(map(str, res)))


n = int(input())
els = list(map(int, input().split(' ')))
un = list(set(els))
ind = []
pairs = []
for u in un:
	pairs.append((u, els[::-1].index(u)))
s = sorted(pairs, key=lambda x: x[1], reverse=True)
print(len(s))
for el in s:
	print(el[0], end=' ')


n = int(input())
array = list(map(int, input().strip().split()))
dodani = set()
new = []
for e in array[::-1]:
	if e not in dodani:
		dodani.add(e)
		new.append(e)
print(len(new))
print(' '.join(list(map(str, new[::-1]))))


n = int(input())
A = list(map(int, input().split()))
d = {}
for (i, a) in enumerate(A):
	d[a] = i
dv = sorted(d.items(), key=lambda x: x[1])
print(len(dv))
print(*[k for (k, v) in dv])


n = int(input())
vec = list(map(int, input().split()))
counter = 0
for i in range(0, len(vec), 1):
	for j in range(i + 1, len(vec), 1):
		if vec[i] == vec[j]:
			vec[i] = 0
			counter += 1
print(len(vec) - counter)
for i in vec:
	if i != 0:
		print(i, end=' ')


n = int(input())
d = {}
for (i, x) in enumerate(map(int, input().split())):
	d[x] = i
(r, s) = zip(*sorted(d.items(), key=lambda a: a[1]))
print(len(r))
print(*r)


from collections import OrderedDict
a = set()
x = int(input())
y = input().split(' ')
y = y[::-1]
b = list(OrderedDict.fromkeys(y))
b = b[::-1]
print(len(b))
print(*b)


n = int(input())
a = list(map(int, input().split()))
ans = list()
for (i, el) in enumerate(a[::-1]):
	if el not in a[::-1][:i]:
		ans.append(el)
print(len(ans))
print(' '.join(map(str, ans[::-1])))


n = int(input())
arr = list(map(int, input().split()))
d = {}
ans = []
for x in arr:
	if x not in d:
		d[x] = 1
	else:
		d[x] += 1
print(len(d))
for x in arr:
	if d[x] == 1:
		ans.append(x)
	else:
		d[x] -= 1
print(*ans)


n = int(input())
a = list(map(int, input().split()))
i = len(a)
ans = 0
for i in range(n // 2):
	(a[i], a[n - i - 1]) = (a[n - i - 1], a[i])
for i in range(n):
	k = a[i]
	c = 0
	for j in range(n):
		if (a[i] == a[j]) & (i != j):
			a[j] = -666
for i in range(n // 2):
	(a[i], a[n - i - 1]) = (a[n - i - 1], a[i])
for i in range(n):
	if a[i] != -666:
		ans = ans + 1
print(ans)
for i in range(n):
	if a[i] != -666:
		print(a[i], end=' ')


n = int(input())
s = list(map(int, input().split(' ')))
s = list(reversed(s))
b = []
for i in s:
	if not i in b:
		b.append(i)
b = list(reversed(b))
print(len(b))
print(*b)


t = int(input())
l = list(map(int, input().split()))
s = set()
for i in l:
	s.add(i)
s = list(s)
print(len(s))
ans = []
for i in l:
	if ans.count(i):
		ans.remove(i)
		ans.append(i)
	else:
		ans.append(i)
for i in ans:
	print(i, end=' ')


n = int(input())
li = list(map(int, input().split()))
s = list(set(li))
i = len(li) - 1
li1 = []
print(len(s))
while i >= 0:
	if li[i] in s:
		li1.append(li[i])
		s.remove(li[i])
	i -= 1
print(*li1[::-1])


n = int(input())
arr = list(map(int, input().split()))
x = []
for i in arr[::-1]:
	if i not in x:
		x.append(i)
print(len(x))
for i in x[::-1]:
	print(i, end=' ')
print()


from collections import Counter, defaultdict
BS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def to_base(s, b):
	res = ''
	while s:
		res += BS[s % b]
		s //= b
	return res[::-1] or '0'
alpha = 'abcdefghijklmnopqrstuvwxyz'
from math import floor, ceil, pi
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919]

def primef(n, plst=[]):
	if n == 1:
		return plst
	else:
		for m in primes:
			if n % m == 0:
				return primef(n // m, plst + [m])
		return primef(1, plst + [n])

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

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

def countOverlapping(string, sub):
	count = start = 0
	while True:
		start = string.find(sub, start) + 1
		if start > 0:
			count += 1
		else:
			return count
n = ii()
nums = lmii()
c = Counter(nums)
print(len(c.keys()))
for i in nums:
	if c[i] > 1:
		c[i] -= 1
	elif c[i] == 1:
		print(i, end=' ')
		c[i] -= 1


n = int(input())
a = list(map(int, input().split()))
arr = []
a = a[::-1]
for i in range(n):
	if arr.count(a[i]) == 0:
		arr.append(a[i])
print(len(arr))
print(' '.join(map(str, arr[::-1])))


n = int(input())
a = list(map(int, input().split()))[::-1]
c = [0] * 1001
ans = []
for x in a:
	if c[x] == 0:
		ans.append(x)
	c[x] += 1
print(len(ans))
print(*ans[::-1])


n = input()
aa = input()
a = [int(s) for s in aa.split(' ')]
a.reverse()
res = []
was_used = set()
for el in a:
	if el not in was_used:
		was_used.add(el)
		res.append(el)
res.reverse()
print(len(res))
print(' '.join([str(x) for x in res]))


n = int(input())
a = input().split()
res = []
for i in range(len(a)):
	if a[i] not in res:
		res.append(a[i])
	else:
		res.remove(a[i])
		res.append(a[i])
print(len(res))
print(*res)


n = int(input())
arr = input()
arr = arr.split(' ')
for i in range(len(arr) - 1, -1, -1):
	try:
		index = arr[:i].index(arr[i])
		del arr[index]
	except ValueError:
		pass
print(len(arr))
print(' '.join((str(x) for x in arr)))


n = int(input())
elements = input().split()
aux = set()
for i in range(len(elements) - 1, -1, -1):
	if elements[i] in aux:
		elements.pop(i)
	else:
		aux.add(elements[i])
print(len(elements))
print(' '.join(elements))


n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
	if a[i] in b:
		b.remove(a[i])
	b.append(a[i])
print(len(b))
for i in b:
	print(i, end=' ')


n = int(input())
arr = []
obj = set()
for i in input().split()[::-1]:
	if int(i) not in obj:
		arr.append(int(i))
		obj.add(int(i))
print(len(arr))
for i in arr[::-1]:
	print(i, end=' ')


n = int(input())
l1 = list(map(int, input().split()))
l2 = []
for i in range(n - 1, -1, -1):
	if l1[i] not in l2:
		l2.append(l1[i])
m = len(l2)
print(m)
for i in range(m - 1, -1, -1):
	print(l2[i], end=' ')


n = int(input())
alist = list(map(int, input().split()))
alist.reverse()
dup = []
for x in alist:
	if x not in dup:
		dup.append(x)
dup.reverse()
print(len(dup))
print(*dup)


q = int(input())
s = input()
n = [int(s) for s in s.split()]
r = []
for i in range(q - 1, -1, -1):
	if n[i] not in r:
		r.append(n[i])
w = len(r) - 1
for i in range(len(r) // 2):
	(r[i], r[w]) = (r[w], r[i])
	w -= 1
	if w <= 0:
		break
print(len(r))
print(' '.join([str(i) for i in r]))


n = int(input())
a = list(map(int, input().split()))
a.reverse()
s = []
for i in range(n):
	if a[i] not in s:
		s.append(a[i])
s.reverse()
print(len(s))
st = ''
for i in range(len(s)):
	st += str(s[i]) + ' '
print(st)


nb = int(input())
liste = [int(x) for x in input().split()]
n = 0
for loop in range(len(liste)):
	if liste.count(liste[n]) != 1:
		liste.pop(n)
		n -= 1
	n += 1
print(len(liste))
for loop in range(len(liste)):
	print(liste[loop], end=' ')


t = int(input())
a = list(map(int, input().split()))
b = []
i = 0
while i < len(a) - 1:
	z = a[i + 1:]
	if a[i] in z:
		a.pop(i)
	else:
		b.append(a[i])
		i += 1
b.append(a[len(a) - 1])
print(len(b))
for i in b:
	print(i, end=' ')
print()


n = int(input())
z = list(map(int, input().split()))
y = []
for i in range(len(z)):
	if z[-i - 1] in y:
		continue
	else:
		y.append(z[-1 - i])
y.reverse()
print(len(y))
for i in range(len(y)):
	if i == len(y) - 1:
		print(y[i])
	else:
		print(y[i], end=' ')


input()
temp = []
ar = [int(x) for x in input().split()]
for x in ar[::-1]:
	if x not in temp:
		temp.append(x)
print(len(temp))
print(*temp[::-1])


n = int(input())
L = [int(x) for x in input().split()]
d = {}
for x in L:
	if x in d:
		del d[x]
		d[x] = 1
	else:
		d[x] = 1
print(len(d))
print(*d.keys())


def funcao(lista):
	tam = len(lista)
	i = 0
	while i < tam:
		j = i + 1
		while j < tam:
			if lista[j] == lista[i]:
				del lista[j]
				tam -= 1
			else:
				j += 1
		i += 1
	return lista
input()
lista = input().split()
lista.reverse()
res = funcao(lista)
res.reverse()
print(len(res))
print(' '.join(res))


n = int(input())
L = [int(x) for x in input().split()]
A = []
for i in range(len(L)):
	if L[-i - 1] not in A:
		A.append(L[-i - 1])
A.reverse()
print(len(set(L)))
print(*A, sep=' ')


A = int(input())
L = []
C = []
L = input().split(' ')
b = len(set(L))
L = list(map(int, L))
print(b)
for i in range(len(L), 0, -1):
	if L[i - 1] not in C:
		C.append(L[i - 1])
C.reverse()
for i in C:
	print(i, end=' ')


n = int(input())
arr = [int(x) for x in input().split()]
stack = []
d = {}
for i in arr[::-1]:
	if not i in d:
		stack += [i]
		d[i] = True
print(len(stack))
print(*stack[::-1])


x = eval(input())
y = input()
y = y.split()
y.reverse()
mp = {}
ans = []
for i in range(0, x):
	if y[i] not in mp:
		ans.append(y[i])
		mp[y[i]] = 1
ans.reverse()
print(len(ans))
for i in range(0, len(ans)):
	print(ans[i], end=' ')


n = int(input())
s = list(map(int, input().split()))
lenS = len(s)
print(len(set(s)))
res = []
for i in range(lenS - 1):
	if not s[i + 1:].count(s[i]):
		res.append(s[i])
if s[lenS - 1] not in res:
	res.append(s[lenS - 1])
print(*res)


n = int(input())
list1 = [int(x) for x in input().split()]
list1.reverse()
list2 = []
for i in range(len(list1)):
	if list1[i] not in list2:
		list2.append(list1[i])
list2.reverse()
print(len(list2))
for i in range(len(list2)):
	print(list2[i], end=' ')
print()


n = int(input())
T = input().split(' ')
for i in range(n):
	T[i] = int(T[i])
L = []
for i in range(n):
	if T[n - 1 - i] not in L:
		L.append(T[n - 1 - i])
print(len(L))
for i in range(len(L) - 1):
	print(L[len(L) - 1 - i], end=' ')
print(L[0])


n = int(input())
a = [int(x) for x in input().split()]
for i in range(len(a) - 1, 0, -1):
	for j in range(i - 1, -1, -1):
		if a[i] == a[j]:
			a[j] = 0
for j in range(a.count(0)):
	a.remove(0)
print(len(a))
print(*a)


def rem(a):
	list1 = []
	for num in a:
		if num not in list1:
			list1.append(num)
	return list1
n = []
x = int(input())
a = [int(x) for x in input().split()]
a.reverse()
b = rem(a)
b.reverse()
print(len(b))
for x in range(len(b)):
	print(b[x], end=' ')


n = int(input())
a = input().split()
ls = [0 for i in range(1001)]
b = []
for i in range(n):
	if ls[int(a[-i - 1])] == 0:
		b.append(a[-i - 1])
		ls[int(a[-i - 1])] = 1
print(len(b))
for i in range(len(b)):
	print(b[-i - 1], end=' ')


n = int(input())
array = list(map(int, input().split()))
array_new = []
for i in range(len(array)):
	if array[i + 1:].count(array[i]) == 0:
		array_new.append(array[i])
print(len(array_new))
print(*array_new)


from collections import Counter
n = int(input())
arr = list(map(int, input().split()))
krr = arr[:]
count = Counter(arr)
se = set(arr)
ind = []
dup = []
final = []
for p in count:
	if count[p] > 1:
		dup.append(p)
	elif count[p] == 1:
		ind.append(arr.index(p))
for i in range(len(arr) - 1, -1, -1):
	if arr[i] in dup:
		ind.append(i)
		dup.remove(arr[i])
ind = sorted(ind)
for k in ind:
	final.append(krr[k])
print(len(se))
for i in final:
	print(i, end=' ')


n = int(input())
l = list(map(int, input().strip().split()))[:n]
distinct = []
for i in range(len(l) - 1, -1, -1):
	if l[i] not in distinct:
		distinct.append(l[i])
print(len(distinct))
print(*distinct[::-1], '')


n = int(input())
k = list(map(int, input().split()))
s = []
t = n - 1
for i in range(n):
	if k[t] not in s:
		s.append(k[t])
	t -= 1
t = len(s) - 1
print(len(s))
for j in range(len(s)):
	print(s[t], end=' ')
	t -= 1


n = int(input())
list1 = list(map(int, input().split(' ')))
list2 = []
list2 = list1[:]
for j in range(0, n - 1):
	if list1[j] in list1[j + 1:]:
		list2.remove(list1[j])
print(len(list2))
for j in list2:
	print(j, end=' ')


n = int(input())
a = input().split(' ')
b = []
for i in range(0, n):
	item = int(a[i])
	if item in b:
		for j in range(0, len(b)):
			if b[j] == item:
				b.pop(j)
				b.append(item)
				break
	else:
		b.append(item)
print(len(b))
for i in range(0, len(b)):
	print(b[i], end=' ')


t = int(input())
x = [int(q) for q in input().split()]
for i in range(len(x) - 1, 0, -1):
	for j in range(i - 1, -1, -1):
		if x[i] == x[j]:
			x[j] = 0
for j in range(x.count(0)):
	x.remove(0)
print(len(x))
print(*x)


n = int(input())
li = list(map(int, input().split()))
ans = []
for l in reversed(li):
	if l not in ans:
		ans.append(l)
print(len(ans))
for a in reversed(ans):
	print(a, end=' ')


n = int(input())
a = list(map(int, input().split()))[::-1]
print(len(set(a)))
print(*sorted(set(a), key=a.index, reverse=True))


n = int(input())
l = [int(x) for x in input().split()]
l = list(reversed(l))
output = []
count = 0
for x in l:
	if x not in output:
		output.append(x)
		count += 1
print(count)
print(' '.join(map(str, reversed(output))))


def main():
	n = int(input())
	d = list(map(int, input().split()))
	l = []
	for i in range(n - 1, -1, -1):
		if d[i] not in l:
			l.append(d[i])
	l.reverse()
	print(len(l))
	print(*l)
main()


n = int(input())
u = list(map(int, input().split()))
s = set()
ans = len(u)
for i in range(n - 1, -1, -1):
	if u[i] not in s:
		s.add(u[i])
	else:
		u[i] = 0
		ans -= 1
print(ans)
for i in u:
	if i > 0:
		print(i, end=' ')


n = int(input())
myset = []
for i in list(input().split())[::-1]:
	if i not in myset:
		myset.append(i)
print(len(myset))
for i in myset[::-1]:
	print(i, end=' ')


import sys
from sys import stdin

def main():
	N = int(stdin.readline())
	A = [int(x) for x in stdin.readline().strip().split()]
	R = set()
	i = N - 1
	while i >= 0:
		if A[i] in R:
			A.pop(i)
		else:
			R.add(A[i])
		i -= 1
	print(len(A))
	for i in range(len(A) - 1):
		print(A[i], end=' ')
	print(A[-1])
main()


from collections import OrderedDict
n = int(input())
q = list(map(int, input().split(' ')))
q.reverse()
q = list(OrderedDict.fromkeys(q))
q.reverse()
print(len(q))
for i in q:
	print(i, end=' ')


n = int(input())
a = [int(x) for x in input().strip().split()]
counter = [False] * 1001
ans = []
i = n - 1
while i >= 0:
	curr = a[i]
	if not counter[curr]:
		ans.append(curr)
		counter[curr] = True
	i -= 1
print(len(ans))
print(' '.join([str(x) for x in reversed(ans)]))


n = int(input())
a = list(map(int, input().split()))
seen = set()
a = reversed(a)
b = []
for x in a:
	if x in seen:
		continue
	else:
		b.append(x)
		seen.add(x)
print(len(b))
print(' '.join((str(x) for x in reversed(b))))


n = int(input())
nums = list()
vals = input().split(' ')
for i in range(n - 1, -1, -1):
	v = int(vals[i])
	if v not in nums:
		nums.append(v)
print(len(nums))
for i in range(len(nums) - 1, 0, -1):
	print(nums[i], end=' ')
print(nums[0])


import sys
sys.setrecursionlimit(10000000)
mod = 10 ** 9 + 7
INF = float('inf')
from sys import stdin
readline = stdin.readline

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

def readTuples():
	return tuple(map(int, readline().split()))

def I():
	return int(readline())
n = I()
from collections import defaultdict
dic = defaultdict(int)
A = readInts()
ans = []
A.reverse()
for i in range(n):
	if dic[A[i]]:
		pass
	else:
		dic[A[i]] = 1
		ans.append(A[i])
print(len(ans))
print(*reversed(ans))


x = int(input())
L = [i for i in input().split()]
L2 = []
for i in L:
	if L.count(i) > 1:
		L2.append(i)
for i in set(L2):
	for j in range(L.count(i) - 1):
		L.remove(i)
S = ' '.join(L)
print(len(L))
print(S)


n = int(input())
x = list(map(int, input().split()))
c = []
for i in range(n - 1, -1, -1):
	if x[i] not in c:
		c.append(x[i])
c.reverse()
print(len(c))
for i in c:
	print(i, end=' ', flush=True)


N = int(input())
S = set()
answer = []
for x in [int(x) for x in input().split()][::-1]:
	if x not in S:
		answer.append(x)
		S.add(x)
print(len(answer))
print(' '.join((str(i) for i in answer[::-1])))


n = int(input())
l = list(map(int, input().split(' ')))
s = []
for x in reversed(l):
	if x not in s:
		s.append(x)
print(len(s))
for x in reversed(s):
	print(x, end=' ')


n = int(input())
elem = set()
arr = []
a = [int(x) for x in input().split()]
for i in range(n - 1, -1, -1):
	if a[i] not in elem:
		arr.append(a[i])
		elem.add(a[i])
arr.reverse()
print(len(arr))
print(*arr)


elementos = int(input())
sequencia = list(map(int, input().split()))
sequencia_aux = [0] * 1001
sequencia_final = []
for i in range(elementos - 1, -1, -1):
	if not sequencia_aux[sequencia[i]]:
		sequencia_final.append(sequencia[i])
		sequencia_aux[sequencia[i]] = 1
final = ''
for i in reversed(sequencia_final):
	final += str(i) + ' '
print(len(sequencia_final))
print(final)


n = int(input())
a = list(map(int, input().split()))
d = dict()
b = []
for i in range(len(a) - 1, -1, -1):
	if a[i] not in d:
		b.append(a[i])
	d[a[i]] = 0
print(len(b))
b.reverse()
print(*b)


from collections import deque
n = int(input())
e = list(map(int, input().split()))
fila = deque()
for i in range(n):
	if e[i] in fila:
		fila.remove(e[i])
		fila.appendleft(e[i])
	else:
		fila.appendleft(e[i])
m = len(fila)
print(m)
saida = ''
for i in range(m):
	saida += '%d ' % fila.pop()
print(saida.strip())


n = int(input())
a = list(map(int, input().split()))
numbers = []
for i in range(n - 1, -1, -1):
	if a[i] in numbers:
		a.pop(i)
	else:
		numbers.append(a[i])
print(len(a))
print(*a)


n = int(input())
arr = list(map(int, input().split()))
arr1 = []
for i in range(n - 1, -1, -1):
	if arr[i] not in arr1:
		arr1.insert(0, arr[i])
print(len(arr1))
print(*arr1)


n = int(input())
a = [int(x) for x in input().split()]
b = []
i = 0
while len(a):
	if a.count(a[0]) > 1:
		a.remove(a[0])
	else:
		b.append(a[0])
		a.remove(a[0])
print(len(b))
for i in b:
	print(i, end=' ')
print()


n = int(input())
a = [int(i) for i in input().split()]
t_r = []
for i in range(n - 1, -1, -1):
	if a[i] not in t_r:
		t_r.append(a[i])
print(len(t_r))
for i in range(len(t_r) - 1, -1, -1):
	print(t_r[i], end=' ')


def read():
	return [int(val) for val in input().split()]

def main():
	n = read()[0]
	a = read()
	b = []
	for v in a[::-1]:
		if v not in b:
			b.append(v)
	print(len(b))
	for v in b[::-1]:
		print(v, end=' ')
main()


n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	if a.count(a[i]) > 1:
		a[i] = []
for i in range(a.count([])):
	a.pop(a.index([]))
print(len(a), ' '.join((str(s) for s in a)), sep='\n')


num = int(input())
numbers = list(map(int, input().split()))
stack = []
numbers.reverse()
for i in numbers:
	if i not in stack:
		stack.insert(0, i)
print(len(stack))
for i in stack:
	print(i, end=' ')


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	p = list(map(int, input().split()))
	s = set()
	p.reverse()
	ans = []
	for i in range(len(p)):
		if p[i] not in s:
			s.add(p[i])
			ans.append(p[i])
	print(len(ans))
	ans.reverse()
	print(*ans)
main()


arrayLength = int(input())
petyasArray = input().split(' ')
seenElements = []
newArrayLength = arrayLength
for i in range(arrayLength - 1, -1, -1):
	if petyasArray[i] in seenElements:
		petyasArray[i] = 0
		newArrayLength -= 1
	else:
		seenElements.append(petyasArray[i])
print(newArrayLength)
newArrayString = ''
for i in range(arrayLength):
	if petyasArray[i] != 0:
		newArrayString += str(petyasArray[i]) + ' '
print(newArrayString[:len(newArrayString) - 1])


n = int(input())
a = list(map(int, input().split()))
addable = [True for _ in range(1001)]
ans = []
for aa in reversed(a):
	if addable[aa]:
		ans.append(aa)
		addable[aa] = False
print(len(ans))
print(*ans[::-1])


n = int(input())
m = list(map(int, input().split()))
(l, k) = ([], [])
for i in m[::-1]:
	if i not in k:
		k.append(i)
	else:
		l.append(i)
print(len(k))
for i in k[::-1]:
	print(i, end=' ')


n = int(input())
l3 = []
l1 = [int(i) for i in input().split(' ')]
for i in range(n):
	t = l1[i]
	l2 = l1[i + 1:]
	if t not in l2:
		l3.append(t)
print(len(l3))
for i in l3:
	print(i, end=' ')


n = int(input())
arr = list(map(int, input().strip().split()))
size = len(set(arr))
result = [None] * size
i = n - 1
j = size - 1
while j >= 0:
	if arr[i] not in result:
		result[j] = arr[i]
		i -= 1
		j -= 1
	else:
		i -= 1
print(len(result))
for ele in result:
	print(ele, end=' ')


T = int(input())
angka = list(map(int, input().split()))
angka.reverse()
newangka = []
for i in range(T):
	if str(angka[i]) not in newangka:
		newangka.append(str(angka[i]))
newangka.reverse()
print(len(newangka))
print(' '.join(newangka))


n = int(input())
arr = input().split()
res = list()
for x in set(arr):
	for i in range(n - 1, -1, -1):
		if x == arr[i]:
			res.append(i)
			break
print(len(res))
for x in sorted(res):
	print(arr[x], end=' ')


n = int(input())
l = list(map(int, input().split()))
x = set(l)
k = []
print(len(x))
for i in range(n - 1, -1, -1):
	if l[i] in x and l[i] not in k:
		k.append(l[i])
print(*k[::-1])


a = int(input())
bg = input().split()
result = []
seen = set()
for i in bg:
	if i not in seen:
		result.append(i)
		seen.add(i)
	else:
		result.remove(i)
		result.append(i)
print(len(result))
for k in result:
	print(int(k), end=' ')


qtd = int(input())
nums = list(map(int, input().split()))
occ = {}
res = []
for i in range(qtd):
	occ[nums[i]] = i
for o in occ:
	res.append((occ[o], o))
res.sort()
print(len(res))
print(*[m for (n, m) in res])


a = []
b = int(input())
list = []
c = input().split(' ')
c = [int(item) for item in c]
c.reverse()
for i in c:
	if i not in list:
		list.append(i)
list.reverse()
print(len(list))
for i in list:
	print(i, end=' ')


n = int(input())
l = list(map(int, input().split()))
t = set(l)
y = len(t)
for i in range(y):
	z = t.pop()
	x = l.count(z)
	for j in range(x - 1):
		l.remove(z)
print(y)
print(*l)


n = int(input())
arr = list(map(int, input().split(' ')))
uniques = list(set(arr))
for i in uniques:
	while arr.count(i) != 1:
		arr.remove(i)
print(len(arr))
for i in arr:
	print(i, end=' ')


n = int(input())
Array = input().split(' ')
new_array = []
for i in Array:
	if i in new_array:
		new_array.remove(i)
		new_array.append(i)
	else:
		new_array.append(i)
print(len(new_array))
for i in new_array:
	print(i, end=' ')


n = int(input())
l = list(map(int, input().split()))
k = list(set(l))
k1 = len(k)
k2 = []
di = dict()
k3 = []
for i in range(k1):
	d = len(l) - 1 - l[::-1].index(k[i])
	k2.append(d)
for i in range(k1):
	di[k2[i]] = k[i]
d1 = sorted(di)
print(len(k))
for i in range(len(d1)):
	k3.append(str(di[d1[i]]))
print(' '.join(k3))


n = input()
l = list(map(int, input().split()))
l1 = []
s = set()
for ele in l:
	s.add(ele)
print(len(s))
for ele in s:
	for i in range(len(l) - 1, -1, -1):
		if ele == l[i]:
			l1.append(i)
			break
l1.sort()
for ele in l1:
	print(l[ele], end=' ')


def main():
	n = int(input())
	a = [i for i in input().split()]
	b = list()
	for i in a:
		if i not in b:
			b.append(i)
		else:
			b.remove(i)
			b.append(i)
	print(len(b))
	print(*b)
main()


n = int(input())
L = list(map(int, input().split()))
L = [L[x] for x in reversed(range(n))]
k = []
for i in L:
	if i not in k:
		k.append(i)
k = [k[x] for x in reversed(range(len(k)))]
print(len(k))
print(*k)


class CodeforcesTask978ASolution:

	def __init__(self):
		self.result = ''
		self.elements_count = 0
		self.elements = []

	def read_input(self):
		self.elements_count = int(input())
		self.elements = [int(x) for x in input().split(' ')]

	def process_task(self):
		new_els = []
		rever = self.elements[::-1]
		for item in rever:
			if item not in new_els:
				new_els.append(item)
		self.result = '{0}\n{1}'.format(len(new_els), ' '.join([str(x) for x in new_els[::-1]]))

	def get_result(self):
		return self.result
Solution = CodeforcesTask978ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


n = int(input())
k = list(map(int, input().split()))
l1 = []
for val in range(len(k) - 1, -1, -1):
	if k[val] not in l1:
		l1.append(k[val])
l1.reverse()
print(len(l1))
print(*l1)


from bisect import bisect_left, bisect_right
n = int(input())
a = list(map(int, input().split()))[::-1]
ans = []
cnt = 0
for i in a:
	if i not in ans:
		cnt += 1
		ans.append(i)
ans = ans[::-1]
print(cnt)
print(*ans)


n = int(input())
b = []
a = []
l = input().split(' ', n)
for i in range(n):
	b.append(int(l[i]))
	a.append(int(l[i]))
for i in a:
	count = 0
	for j in b:
		if i == j:
			if count > 0:
				temp = i
				b.remove(temp)
			else:
				count = count + 1
print(len(b))
for i in range(len(b)):
	print(b[i], end=' ')


import collections
visited = collections.defaultdict(bool)
n = int(input())
A = list(map(int, input().split()))
res = []
for i in range(n - 1, -1, -1):
	if visited[A[i]] == False:
		visited[A[i]] = True
	else:
		A[i] = None
res = list(filter(lambda x: x != None, A))
print(len(res))
print(*res)


input()
l = []
lst = list(map(int, input().split()))
for i in lst:
	if i in l:
		l.remove(i)
	l.append(i)
print(len(l))
print(*l)


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

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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

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

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

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

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

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

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

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

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

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

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

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

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

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

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

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

def solve():
	n = int(inp())
	a = lis()[::-1]
	cnt = [0] * 1001
	ans = []
	for i in range(0, n):
		if cnt[a[i]] == 0:
			ans.append(a[i])
			cnt[a[i]] += 1
	print(len(ans))
	print(*ans[::-1])
testcase(1)


input()
a = list((int(x) for x in input().split(' ')))
out = list()
for d in reversed(a):
	if d not in out:
		out.append(d)
print(len(out))
s = ' '.join((str(x) for x in reversed(out)))
print(s)


n = int(input())
A = tuple(map(int, input().split()))
S = []
for i in reversed(A):
	if i not in S:
		S.append(i)
print(len(S))
print(' '.join(tuple(map(str, reversed(S)))))


from sys import stdin
from collections import Counter
stdin.readline()
nums = list(map(int, stdin.readline().rstrip().split(' ')))
l = Counter()
for (i, e) in enumerate(nums):
	l[e] = i
print(len(l))
for (element, index) in reversed(l.most_common()):
	print('{} '.format(element), end='')


n = input()
s = list(map(int, input().split()))
for i in s[-1::-1]:
	while s.count(i) - 1:
		s.remove(i)
print(len(s))
for i in s:
	print(i, end=' ')


n = int(input())
t = []
arr = input().split()
for i in arr:
	if i in t:
		t.remove(i)
	t.append(i)
print(len(t))
print(*t)


n = int(input().strip())
arr = [int(i) for i in input().strip().split()]
l = []
for i in range(n - 1, -1, -1):
	if arr[i] not in l:
		l.append(arr[i])
print(len(l))
print(' '.join([str(i) for i in l][::-1]))


n = int(input())
arr = list(map(int, input().split()))
arr.reverse()
lst = list(dict.fromkeys(arr))
lst.reverse()
print(len(lst))
print(*lst, sep=' ')


n = int(input())
a = [int(x) for x in input().split()]
r = []
for i in reversed(a):
	if i not in r:
		r.insert(0, i)
print(len(r))
for i in r:
	print(i, end=' ')


n = int(input())
arr = [int(x) for x in input().split()]
brr = []
c = []
for i in range(0, n, 1):
	brr = arr[i + 1:]
	if arr[i] in brr:
		continue
	else:
		c.append(arr[i])
print(len(c))
print(*c)


tamanho_entraada = input()
entrada = input().split(' ')
lista_de_letra_sem_repeticao = []
for indice in range(len(entrada) - 1, -1, -1):
	letra = entrada[indice]
	if not letra in lista_de_letra_sem_repeticao:
		lista_de_letra_sem_repeticao.append(letra)
print(len(lista_de_letra_sem_repeticao))
lista_de_letra_sem_repeticao.reverse()
print(' '.join(lista_de_letra_sem_repeticao))


from collections import deque

def dupli(d, n):
	pos = deque()
	i = n - 1
	while i >= 0:
		if i in pos:
			i -= 1
			continue
		j = i - 1
		while j >= 0:
			if d[j] == d[i]:
				pos.append(j)
			j -= 1
		i -= 1
	c = [d[i] for i in range(n) if i not in pos]
	return c
n = int(input())
d = list(map(int, input().rstrip().split()))
d = dupli(d, n)
print(len(d))
for i in d:
	print(i, end=' ')


n = int(input())
arr = list(map(int, input().split(' ')))
for i in range(n):
	if arr.count(arr[i]) > 1:
		arr[i] = 0
ans = []
for i in range(n):
	if arr[i] != 0:
		ans.append(arr[i])
print(len(ans))
print(*ans)


input()
a = input().split()
i = 0
while i < len(a):
	if a.count(a[i]) == 1:
		i += 1
	else:
		d = a[i]
		for j in range(a.count(a[i]) - 1):
			a.remove(d)
print(len(a))
print(' '.join(a))


n = int(input())
block = []
s = list(map(int, input().split()))
a = s[::-1]
rest = []
count = 0
for i in range(n):
	if a[i] not in block:
		rest.append(str(a[i]))
		block.append(a[i])
		count += 1
rest = rest[::-1]
res = ''
for i in range(count):
	res += rest[i] + ' '
print(count)
print(res)


import sys
next(sys.stdin)
xs = list(map(int, next(sys.stdin).rstrip().split()))
x2id = {}
for (i, x) in enumerate(xs):
	x2id[x] = i
result = []
for (i, x) in enumerate(xs):
	if x2id[x] == i:
		result.append(x)
print(len(result))
print(' '.join(map(str, result)))


n = int(input())
a = list(map(int, input().split()))
res = []
used = [False] * 1001
for x in a[::-1]:
	if not used[x]:
		res.append(x)
		used[x] = True
print(len(res))
print(' '.join(map(str, res[::-1])))


input()
a = [int(i) for i in input().split()]
l = []
for i in range(len(a) - 1, -1, -1):
	if not a[i] in a[i + 1:len(a)]:
		l.append(a[i])
print(len(l))
for i in l[::-1]:
	print(i, end=' ')


n = int(input())
nums = list(map(int, input().split()))
new = []
output = []
for i in range(len(nums)):
	new.append(nums[len(nums) - i - 1])
for j in range(len(new)):
	if new[j] not in output:
		output.append(new[j])
print(len(output))
for k in range(len(output)):
	print(output[len(output) - k - 1], end=' ')


n = int(input())
a = list(map(int, input().split()))
result = []
for i in range(n):
	rindx = n - a[-1::-1].index(a[i]) - 1
	cindx = i
	if rindx == cindx:
		result.append(a[i])
print(len(result))
print(' '.join((str(s) for s in result)))


def ip():
	return int(input())

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

def sar():
	return list(ipp())

def pars(a):
	print(' '.join(list(map(str, a))))
	print('\r')

def parl(a):
	print('\r'.join(list(map(str, a))))
	print('\r')
T = 1
for _ in range(T):
	n = ip()
	a = sar()
	a = a[::-1]
	mp = {}
	ans = []
	for i in a:
		if i not in mp:
			mp[i] = 1
			ans.append(i)
	ans = ans[::-1]
	print(len(ans))
	pars(ans)


n = int(input())
a = list(map(int, input().split()))
cnt = [0] * max(a)
print(len(set(a)))
for i in range(n):
	cnt[a[i] - 1] += 1
for i in range(n):
	cnt[a[i] - 1] -= 1
	if cnt[a[i] - 1] == 0:
		print(a[i], end=' ')


n = int(input())
lst = []
lst = list(map(int, input().split()))
lst1 = []
lst1.append(lst[0])
for i in range(1, n):
	lst1.append(lst[i])
	lst2 = []
	for j in range(0, len(lst1) - 1):
		if lst[i] == lst1[j]:
			lst2.append(lst1[j])
	if len(lst2):
		for i in lst2:
			lst1.remove(i)
print(len(lst1))
for i in lst1:
	print(i, end=' ')


T = int(input())
l = list(map(int, input().split()))
L = []
r = l[::-1]
for i in r:
	if i not in L:
		L.append(i)
R = L[::-1]
print(len(R))
print(*R)


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
Read = lambda : list(map(int, input().split()))
Num = lambda : int(input())
exec("try:sys.stdin=open('in.txt','r');sys.stdout=open('out.txt','w')\nexcept:pass")

def solve():
	n = Num()
	a = Read()[::-1]
	(s, ans) = (set(), [])
	for i in a:
		if i not in s:
			s.add(i)
			ans.append(i)
	print(len(ans))
	print(*ans[::-1])
solve()


n = int(input())
a = list(map(int, input().split()))
ans = []
s = set()
for x in a[::-1]:
	if x in s:
		continue
	else:
		s.add(x)
		ans.append(x)
print(len(ans))
print(*ans[::-1])


n = int(input())
l = list(map(int, input().split()))
for i in range(n - 1):
	if l[i] in l[i + 1:]:
		l[i] = 0
while 0 in l:
	l.remove(0)
print(len(l))
print(*l, sep=' ')


n = int(input())
m = list(map(int, input().split()))
new_m = []
for elem in m[::-1]:
	if elem not in new_m:
		new_m = [elem] + new_m
print(len(new_m))
print(*new_m)


n = input()
l = input().split()[::-1]
print(len(set(l)))
print(*sorted(set(l), key=l.index, reverse=True))


n = int(input())
x = input().split()
d = {}
result = ''
for i in range(n - 1, -1, -1):
	d[x[i]] = x[i]
print(len(d))
for i in d:
	result = i + ' ' + result
print(result)


import bisect
n = int(input())
arr = [int(x) for x in input().split()]
chk = [False for x in range(1001)]
arr.reverse()
ans = list()
for i in range(n):
	if not chk[arr[i]]:
		ans.append(arr[i])
		chk[arr[i]] = True
ans.reverse()
print(len(ans))
for a in ans:
	print(a, end=' ')


from copy import deepcopy
input()
data_list = list(input().split())
c = 0
for i in range(len(data_list) - 1):
	ci = i - c
	if data_list.count(data_list[ci]) > 1:
		data_list.pop(ci)
		c += 1
s = ' '
print(len(data_list))
print(s.join(data_list))


import sys
n = int(sys.stdin.readline())
line = sys.stdin.readline().split()[::-1]
new = []
for j in range(n):
	if new.count(line[j]) == 0:
		new.append(line[j])
print(len(new))
print(' '.join(new[::-1]))


n = int(input())
nums = set()
arr = list(map(int, input().split()))
arr.reverse()
ans = []
for _ in arr:
	if _ not in nums:
		nums.add(_)
		ans.append(_)
ans.reverse()
print(len(ans))
print(*ans)


n = int(input())
l = list(map(int, input().split(' ')))
l1 = []
for i in range(n):
	if l.count(l[i]) == 1:
		l1.append(i)
	else:
		p = len(l) - 1 - l[::-1].index(l[i])
		if p in l1:
			pass
		else:
			l1.append(p)
l1.sort()
for i in range(len(l1)):
	l1[i] = l[l1[i]]
print(len(l1))
print(*l1, end=' ')


n = int(input())
l = list(map(int, input().split()))
print(len(set(l)))
for i in range(n):
	if l[i] not in l[i + 1:]:
		print(l[i], end=' ')


myset = set()
s = input()
s = input().split()
l = list()
for i in s[::-1]:
	if i not in myset:
		myset.add(i)
		l.append(i)
print(len(l))
print(*l[::-1])


def main():
	n = int(input())
	a = list(map(int, input().split(' ')))
	check = [False for i in range(10001)]
	counter = 0
	res = []
	for i in range(n - 1, -1, -1):
		if check[a[i]]:
			counter = counter + 1
			a[i] = -1
		else:
			check[a[i]] = True
			res.append(a[i])
	print(n - counter)
	res.reverse()
	print(*res, sep=' ')
main()


n = int(input())
a = [int(x) for x in input().split()]
for i in range(n):
	if a.count(a[i]) > 1:
		a[i] = []
for i in range(a.count([])):
	a.pop(a.index([]))
print(len(a))
for i in a:
	print(i, end=' ')


n = int(input())
a = [i for i in input().split(' ')]
ans_set = []
for i in range(n - 1, -1, -1):
	if a[i] not in ans_set:
		ans_set.append(a[i])
ans_set.reverse()
print(len(ans_set))
for i in ans_set:
	print(i, end=' ')


from sys import stdin, stdout
import random
import time

def removeDup(arr):
	new = []
	seen = []
	for i in range(len(arr) - 1, -1, -1):
		if arr[i] not in seen:
			seen.append(arr[i])
			new.append(arr[i])
	new = new[::-1]
	return (len(new), new)
n = int(input())
arr = [int(x) for x in input().rstrip().split()]
(n, arr) = removeDup(arr)
print(n)
for a in arr:
	print(a, end=' ')

def threepal(n):
	s = [0 for x in range(n)]
	all_choices = ['a', 'b', 'c']
	preferred_choices = ['a', 'b']
	if n == 0:
		return ''
	if n == 1:
		return random.choice(preferred_choices)
	for i in range(2):
		s[i] = random.choice(preferred_choices)
	for i in range(2, int(n / 1)):
		if s[i - 2] == 'a':
			s[i] = 'b'
		else:
			s[i] = 'a'
	return ''.join(s)

def decrypt(t, n):
	for i in range(2, n):
		if n % i == 0:
			t = t[i - 1::-1] + t[i:]
	t = t[::-1]
	return t

def beautifulString(s):
	letters = set(('a', 'b', 'c'))
	for i in range(len(s)):
		if i < len(s) - 1:
			if s[i] != '?' and s[i] == s[i + 1]:
				return -1
		if s[i] == '?':
			usedLetters = set()
			if i < len(s) - 1:
				usedLetters.add(s[i + 1])
			if i > 0:
				usedLetters.add(s[i - 1])
			remaining = list(letters - usedLetters)
			new_character = random.choice(remaining)
			s[i] = new_character
	return ''.join(s)


n = int(input())
arr = [int(a) for a in input().strip().split(' ')]
count = 0
s = []
r_arr = arr[::-1]
for i in range(n):
	if r_arr[i] not in s:
		s.append(r_arr[i])
	else:
		r_arr[i] = 0
		count += 1
print(n - count)
arr = r_arr[::-1]
for a in arr:
	if a != 0:
		print(a, end=' ')


n = int(input())
a = list(map(int, input().split()))
b = []
for x in a[::-1]:
	if x not in b:
		b += (x,)
print(len(b))
print(*b[::-1])


a = int(input())
b = list(map(int, input().split()))
c = []
for i in b:
	if i in c:
		c.remove(i)
	c.append(i)
print(len(c))
print(*c)


n = int(input())
ai = list(map(int, input().split()))
dic = {}
for i in ai:
	if i not in dic:
		dic[i] = 1
	else:
		dic[i] += 1
arr = ai[::-1]
for (k, v) in dic.items():
	while v != 1:
		ai.remove(k)
		v -= 1
print(len(ai))
print(*ai)


import sys
from collections import Counter

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

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

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

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

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

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

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
N = INT()
A = LIST()
S = set()
ans = []
for i in range(N - 1, -1, -1):
	if A[i] not in S:
		S.add(A[i])
		ans.append(A[i])
ans = ans[::-1]
print(len(ans))
print(*ans)


N = int(input())
arr = [int(k) for k in input().split(' ')]
rev = []
for i in arr[::-1]:
	if i not in rev:
		rev.append(i)
print(len(rev))
for i in rev[::-1]:
	print(i, end=' ')


n = int(input())
a = list(map(int, input().split()))
su = len(set(a))
s = [None] * su
for i in range(n - 1, -1, -1):
	if a[i] in s:
		continue
	else:
		s[su - 1] = a[i]
		su -= 1
print(len(set(a)))
for i in s:
	print(i, end=' ')
print()


n = int(input())
a = list(map(int, input().split()))
f = [0] * 1010
ans = []
for v in reversed(a):
	if f[v] == 0:
		ans.append(v)
	f[v] += 1
print(len(ans))
ans = reversed(ans)
print(*ans)


n = int(input())
m = list(map(int, input().split()))
l = []
m = reversed(m)
for i in m:
	if i not in l:
		l.append(i)
print(len(l))
l = reversed(l)
print(*l)


try:
	n = int(input())
	arr = list(map(int, input().split()))
	arr.reverse()
	for i in range(0, n):
		for j in range(i + 1, n):
			if arr[i] == arr[j]:
				arr[j] = 0
	res = list(filter(lambda a: a != 0, arr))
	res.reverse()
	print(len(res))
	for ele in res:
		print(ele, end=' ')
	pass
except Exception:
	pass


n = int(input())
a = input().split()
b = []
met = set()
for x in range(n - 1, -1, -1):
	if a[x] not in met:
		b.append(a[x])
		met.add(a[x])
b = b[::-1]
print(len(b))
print(' '.join(b))


def eliminate_duplicates():
	inputs = int(input())
	tests = input().split()
	dic = {}
	i = -1
	while True:
		if tests[i] not in dic:
			dic[tests[i]] = 0
			i -= 1
		else:
			tests.pop(i)
		if -i == len(tests) + 1:
			output = ''
			print(len(tests))
			for i in tests:
				if len(output) == 0:
					output = i
				else:
					output = output + ' ' + i
			print(output)
			return
eliminate_duplicates()


n = int(input())
m = list(map(int, input().split()))
v = []
for i in range(len(m) - 1, -1, -1):
	if not m[i] in v:
		v.append(m[i])
v.reverse()
print(len(v))
print(*v)


x = int(input())
x1 = [int(x) for x in input().split()]
x2 = set()
x1 = x1[::-1]
b = []
d = set()
for i in range(x):
	x = x1[i]
	if x in d:
		continue
	else:
		d.add(x1[i])
		b.append(x1[i])
print(len(b))
for i in range(len(b) - 1, -1, -1):
	print(b[i], end=' ')


n = int(input())
a = list(map(str, input().split()))
b = []
for i in a:
	if i in b:
		b.remove(i)
	b.append(i)
print(len(b))
print(*b)


def main():
	n = int(input())
	x = list(map(int, input().split()))
	dict1 = {}
	result = []
	for i in x[::-1]:
		if i in dict1.keys():
			pass
		else:
			dict1[i] = 1
			result.append(i)
	print(len(result))
	print(*result[::-1], sep=' ')
main()


input()
a = list(map(int, input().split()))
r = set()
n = []
for e in a[::-1]:
	if e in r:
		continue
	r.add(e)
	n.append(e)
print(len(n))
print(' '.join((str(x) for x in n[::-1])))


n = int(input())
a = list(map(int, input().split()))[::-1]
i = 0
r = []
for i in a:
	if not i in r:
		r += [i]
print(len(r))
for i in r[::-1]:
	print(i, end=' ')


(n, a, b, d) = (int(input()), '', set(), 0)
c = input().split()
for i in range(n):
	i = c[n - 1 - i]
	if i not in b:
		a = str(i) + ' ' + a
		b.add(i)
		d += 1
print(d)
print(a)


n = int(input())
a = input().split()
s = set(a)
for x in s:
	while a.count(x) != 1:
		a.remove(x)
print(len(a))
print(' '.join(a))


n = int(input())
buckets = [False for i in range(1001)]
sequence = [k for k in map(int, input().split())]
for k in sequence:
	buckets[k] = True
result = []
for i in range(n - 1, -1, -1):
	if buckets[sequence[i]]:
		result.append(str(sequence[i]))
		buckets[sequence[i]] = False
result.reverse()
print(len(result))
print(' '.join(result))


from collections import Counter
n = int(input())
a = list(map(int, input().split()))[::-1]
ans = list(Counter(a).keys())[::-1]
print(len(ans))
for i in ans:
	print(i, end=' ')


import math
k = input()
n = input().split(' ')
ans = {}
i = int(k) - 1
a = []
while i >= 0:
	if n[i] in ans:
		i -= 1
		continue
	else:
		ans[n[i]] = 1
		a.append(n[i])
	i -= 1
i = len(a) - 1
print(len(a))
while i >= 0:
	print(a[i], end=' ')
	i -= 1
print()


from collections import OrderedDict
n = int(input())
d = OrderedDict()
p = []
l = list(map(int, input().split()))
l = l[::-1]
for i in l:
	if i not in d:
		d[i] = 1
for i in d.keys():
	p.append(i)
p = p[::-1]
print(len(p))
print(*p)


n = input()
a = list(map(int, input().split()))[::-1]
b = []
for element in a:
	if element not in b:
		b += [element]
print(len(b))
for element in b[::-1]:
	print(element, end=' ')


dic = {}
MyList = []
input()
X = list(map(int, input().strip().split(' ')))
for x in X[::-1]:
	if x not in dic.keys():
		MyList.append(x)
		dic[x] = True
print(len(MyList))
print(*MyList[::-1])


n = int(input())
a = list(map(int, input().split()))
used = set()
answer = []
for i in range(n - 1, -1, -1):
	if a[i] in used:
		continue
	answer.append(a[i])
	used.add(a[i])
print(len(answer))
print(*reversed(answer))


n = int(input())
a = [int(i) for i in input().split()]
a.reverse()
b = [0] * 1500
c = []
for i in a:
	if b[i] == 0:
		b[i] = 1
		c.append(i)
c.reverse()
print(len(c))
print(' '.join((str(x) for x in c)))


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

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

def si():
	return input()

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

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

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

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
import sys
input = sys.stdin.readline
scanner = lambda : int(input())
string = lambda : input().rstrip()
get_list = lambda : list(read())
read = lambda : map(int, input().split())
get_float = lambda : map(float, input().split())

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

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

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

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

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

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

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

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

def comb(n, x):
	(a, b) = (1, 1)
	for i in range(1, x + 1):
		a *= n + 1 - i
		b *= i
	return a // b % MOD

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

def check(moves, n):
	val = (moves + 1) // 2
	rem = moves - val
	sol = (val + 1) * (rem + 1)
	return sol < n

def sortSecond(val):
	return val[1]
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
small = 'abcdefghijklmnopqrstuvwxyz'
large = small.upper()
from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect
import functools as fnt
from decimal import Decimal

def solve(i):
	n = scanner()
	a = get_list()
	ans = []
	mp = {}
	for x in a[::-1]:
		if mp.get(x) == None:
			ans.append(x)
			mp[x] = 1
	print(len(ans))
	print(*ans[::-1])
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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

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


n = int(input())
l = list(map(int, input().split()))
m = l[:]
for i in range(n):
	if l[i] in l[i + 1:]:
		m.remove(l[i])
print(len(m))
print(' '.join([str(i) for i in m]))


N = int(input())
a = input().split(' ')
import collections
c = collections.Counter(a)
import sys
i = 0
while i < len(c):
	if a.count(a[i]) != 1:
		a.remove(a[i])
	else:
		i += 1
print(len(a))
print(' '.join(a))


n = int(input())
nums = list(map(int, input().split()))
right_most = {}
for i in range(n):
	num = nums[i]
	right_most[num] = i
ans = ''
ans_amount = 0
for i in range(n):
	num = nums[i]
	if right_most[num] == i:
		ans += str(num)
		ans += ' '
		ans_amount += 1
print(ans_amount)
print(ans)


qty = input()
numbers = input()
res = list()
uniques = set()
for num in reversed(numbers.split()):
	if num not in uniques:
		res.append(num)
		uniques.add(num)
print(len(res))
print(' '.join(reversed(res)))


input()
a = [int(s) for s in input().split()]
i = 0
while i < len(a):
	if a.count(a[i]) > 1:
		a.pop(i)
		i -= 1
	i += 1
print(len(a))
print(' '.join([str(i) for i in a]))


n = int(input())
a = [int(x) for x in input().split()]
a = a[::-1]
d = []
for i in a:
	if i not in d:
		d.append(i)
d = d[::-1]
print(len(d))
for i in d:
	print(i, sep=' ', end=' ')


import collections
n = int(input())
lis = [*map(int, input().split())]
ans = collections.deque()
for i in range(n - 1, -1, -1):
	if lis[i] not in ans:
		ans.appendleft(lis[i])
print(len(ans))
print(*ans)


n = int(input())
l = [int(x) for x in input().split()]
print(len(set(l)))
for i in range(n):
	if l[i] not in l[i + 1:n]:
		print(l[i], end=' ')
print()


x = int(input())
h = list(map(int, input().split()))
h.reverse()
l = len(h)
for i in range(l - 1):
	j = i
	while j < l - 1:
		if h[i] == h[j + 1]:
			del h[j + 1]
			l = l - 1
			j = j - 1
		j = j + 1
h.reverse()
print(len(h))
for i in h:
	print(i, end=' ')


n = input()
a = [int(ai) for ai in input().split(' ')][::-1]
from collections import OrderedDict
ans = list(OrderedDict.fromkeys(a))
print(len(ans))
print(*ans[::-1])


input()
f = []
for i in list(map(int, input().split()))[::-1]:
	if i not in f:
		f.append(i)
print(len(f))
print(*f[::-1])


n = int(input())
ar = list(map(int, input().strip().split(' ')))
ar.reverse()
t = []
for each in ar:
	if each not in t:
		t.append(each)
print(len(t))
t.reverse()
for each in t:
	print(each, end=' ')


out_put = []
number_of_inputs = input()
line = input().split()
for e in line:
	e = int(e)
	out_put.append(e)
seen = []
i = int(number_of_inputs) - 1
while i != -1:
	if out_put[i] in seen:
		out_put.pop(i)
	else:
		seen.append(out_put[i])
	i -= 1
print(len(out_put))
for e in out_put:
	print(e, end=' ')


n = int(input())
A = [*map(int, input().split())]
S = set()
O = []
for i in range(n - 1, -1, -1):
	if A[i] not in S:
		O.append(A[i])
		S.add(A[i])
O = O[::-1]
print(len(O))
print(' '.join(map(str, O)))


n = int(input())
s = set()
a = []
for i in reversed(list(map(int, input().split()))):
	if i not in s:
		s.add(i)
		a.append(i)
print(len(a))
print(*reversed(a))


n = int(input())
a = [int(i) for i in input().split()]
a.reverse()
a = list(dict.fromkeys(a))
a.reverse()
print(len(a))
for i in range(len(a)):
	print(a[i], end=' ')


__author__ = 'Dilshod'
n = int(input())
m = list(map(int, input().split()))
m.reverse()
without_dubl = []
for i in range(n):
	if m[i] not in without_dubl:
		without_dubl.insert(0, m[i])
print(len(without_dubl))
print(*without_dubl, sep=' ')


n = int(input())
a = [int(x) for x in input().split()]
a.reverse()
b = []
for i in range(n):
	element_was_not = True
	for j in range(i):
		if a[i] == a[j]:
			element_was_not = False
	if element_was_not:
		b.append(a[i])
b.reverse()
print(len(b))
for x in b:
	print(x, end=' ')


n = int(input())
li = list(map(int, input().split()))
a = []
for i in range(n):
	v = 1
	for j in a:
		if j[0] == li[i]:
			v = 0
			j[1] = i
			break
	if v:
		a.append([li[i], i])
a = sorted(a, key=lambda x: x[1])
print(len(a))
for i in a:
	print(i[0], end=' ')


n = int(input())
a = list(map(int, input().split()))
i = 0
while i < len(a):
	p = a[i]
	k = a.count(a[i])
	if k >= 2:
		for j in range(k - 1):
			a.remove(p)
		i = i + 0
	else:
		i += 1
print(len(a))
for i in a:
	print(i, end=' ')


N = int(input())
array = [int(i) for i in input().split()]
i = 0
while i < len(array):
	if array[i] in array[i + 1:]:
		array = array[:i] + array[i + 1:]
	else:
		i += 1
print(len(array))
for k in array:
	print(k, end=' ')


input()
a = input().split()
b = set(a)
c = []
for i in a[::-1]:
	if i in b:
		c.append(i)
		b.remove(i)
print(len(c))
print(' '.join(reversed(c)))


n = input()
a = list(map(int, input().split()))
for x in set(a):
	[a.remove(x) for _ in range(a.count(x) - 1)]
print(len(a))
print(*a)


x = int(input())
y = input().split()[::-1]
print(len(set(y)))
print(*sorted(set(y), key=y.index, reverse=True))


n = int(input())
files = list(map(int, input().split()))
resalt = []
while len(files) > 0:
	kil = []
	now = files[len(files) - 1]
	resalt.append(now)
	for i in range(len(files)):
		if files[i] == now:
			kil.append(i)
	for i in range(len(kil)):
		files.pop(kil[i] - i)
print(len(resalt))
for i in range(len(resalt) - 1, -1, -1):
	print(resalt[i], end=' ')


n = int(input())
a = list(map(int, input().split()))
f = [0] * 1001
for i in a:
	f[i] = 1
fl = [0] * 1001
s = []
t = 0
for i in a[::-1]:
	if fl[i] == 0:
		s.append(i)
		t += 1
	elif f[i] == 0:
		s.append(i)
		t += 1
	fl[i] = 1
s.reverse()
print(t)
print(*s)


length = int(input())
l = input().split(' ')
l = [int(e) for e in l]
assert length == len(l)
s = {}
to_delete = []
for (i, num) in enumerate(l):
	s[num] = i
no_del = s.values()
for i in range(len(l) - 1, -1, -1):
	if i not in no_del:
		l.pop(i)
print(len(l))
print(l[0], end='')
for e in l[1:]:
	print(' ', end='')
	print(e, end='')


n = int(input())
ar = list(map(int, input().split()))
dic = {}
ar.reverse()
nar = []
for x in ar:
	if dic.get(x) is None:
		nar.append(x)
		dic[x] = True
nar.reverse()
print(len(nar))
print(*nar)


n = int(input())
L = [int(x) for x in input().split()]
d = {}
for i in range(n):
	d[L[i]] = i
a = []
for x in d:
	a.append((d[x], x))
a.sort()
r = []
for x in a:
	r.append(x[1])
print(len(r))
print(*r)


n = int(input())
l = list(map(int, input().split()))
ls = list(set(l))
for i in ls:
	if l.count(i) > 1:
		for k in range(l.count(i) - 1):
			l.remove(i)
print(len(l))
print(*l)


n = int(input())
l = [int(i) for i in input().split()]
l.reverse()
i = 0
while i < len(l):
	k = l[i]
	j = i + 1
	while j < len(l):
		if l[j] == k:
			l = l[:j] + l[j + 1:]
		else:
			j += 1
	i += 1
print(len(l))
l.reverse()
print(*l)


n = int(input())
hashi = dict()
l = input().split()
li = [int(i) for i in l]
for i in range(n):
	hashi[li[i]] = i
l = []
for i in range(n):
	if hashi[li[i]] == i:
		l.append(li[i])
print(len(l))
for i in l:
	print(i, end=' ')
print()


n = int(input())
a = list(map(int, input().split()))
l = []
for i in range(n):
	el = a[-1 - i]
	if el not in l:
		l.append(el)
l.reverse()
print(len(l))
for el in l:
	print(el, end=' ')


def remove_duplicates(arr):
	existing_values = set()
	for i in range(len(arr) - 1, -1, -1):
		if arr[i] in existing_values:
			arr.pop(i)
		else:
			existing_values.add(arr[i])
n = int(input())
numbers = list(map(int, input().split()))
remove_duplicates(numbers)
print(len(numbers))
print(' '.join(map(str, numbers)))


def duplicate(arr):
	ans = []
	for i in arr:
		if i in ans:
			ans.remove(i)
			ans.append(i)
		else:
			ans.append(i)
	print(len(ans))
	for i in ans:
		print(i, '', end='')
	print()
n = int(input())
arr = list(map(int, input().rstrip().split()))
duplicate(arr)


input()
r = []
for x in list(map(int, input().split()))[::-1]:
	if not x in r:
		r.append(x)
print(len(r))
print(*r[::-1])


n = int(input())
a = [int(x) for x in input().split()]
ansNum = 0
ansStr = ''
currentIndex = 0
while currentIndex < len(a):
	if a.count(a[currentIndex]) > 1:
		a.remove(a[currentIndex])
	else:
		ansNum += 1
		ansStr += str(a[currentIndex]) + ' '
		currentIndex += 1
print(ansNum)
print(ansStr)


import math
import os
import random
import re
from sys import stdin, stdout
from collections import Counter
from itertools import permutations

def si():
	return str(stdin.readline())

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

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

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

def debug(x):
	return stdout.write(str(x))
n = ii()
arr = li()
ans = []
for i in range(n - 1, -1, -1):
	if arr[i] not in ans:
		ans.append(arr[i])
ans.reverse()
print(len(ans))
print(' '.join((str(e) for e in ans)))


n = int(input())
l = list(map(int, input().split()))[:n]
d = []
d = d + l
for i in range(len(l)):
	if d.count(l[i]) > 1:
		d.remove(l[i])
print(len(d))
for i in range(len(d)):
	print(d[i], end=' ')


n = int(input())
a = list(map(int, input().split()))
b = list(set(a))
c = []
for i in range(len(b)):
	x = a.count(b[i])
	if x > 1:
		for j in range(x - 1):
			a.remove(b[i])
print(len(a))
for i in range(len(a)):
	print(a[i], end=' ')


n = int(input())
li = list(map(int, input().split()))
dic = {}
for i in range(n):
	dic[li[i]] = i
dic = sorted(dic.items(), key=lambda x: x[1])
print(len(dic))
for i in dic:
	print(i[0], end=' ')


num = int(input())
arr = list(map(int, input().split()))
lst = []
arr = arr[::-1]
for x in arr:
	if x not in lst:
		lst.append(x)
print(len(lst))
print(*lst[::-1])


def my_recursive_function(sequence, index):
	if index <= 0:
		return sequence
	else:
		i = index - 1
		while i > -1:
			if sequence[i] == sequence[index]:
				sequence.pop(i)
				index -= 1
			i -= 1
		my_recursive_function(sequence, index - 1)
n = int(input())
sequence = list(map(str, input().split()))
my_recursive_function(sequence, n - 1)
print(len(sequence))
print(' '.join(sequence))


from collections import deque
s = int(input())
a = list(map(int, input().split()))
b = deque()
for n in reversed(a):
	if n not in b:
		b.appendleft(n)
print(len(b))
print(*b)


def duplicates(n, a):
	b = list()
	for elem in a:
		b.append(n - a[::-1].index(elem) - 1)
	c = sorted(list(set(b)))
	d = list()
	for elem in c:
		d.append(a[elem])
	print(len(d))
	return d
m = int(input())
lst = [int(j) for j in input().split()]
print(*duplicates(m, lst))


n = int(input())
l = list(map(int, input().split()))
l = l[::-1]
r = []
for e in l:
	if e not in r:
		r.append(e)
print(len(r))
print(*r[::-1])


n = input()
numbers = input().split()
new_numbers = set()
for i in numbers[::-1]:
	if i in new_numbers:
		numbers.remove(i)
	else:
		new_numbers.add(i)
print(len(numbers))
for i in numbers:
	print(i, end=' ')
print()


n = int(input())
l = list(map(int, input().split()))
s = set(l)
ans = []
for i in reversed(l):
	if i in s:
		s.remove(i)
		ans.append(i)
print(len(ans))
print(*reversed(ans))


from collections import *
n = int(input())
l = [int(x) for x in input().split()]
h = Counter(l)
q = deque()
count = 0
for i in l:
	if h[i] == 1:
		count += 1
		q.append(i)
	h[i] -= 1
print(count)
for i in q:
	print(i, end=' ')


no_of_ele = int(input())
count_dict = {}
elements = [int(ele) for ele in input().split()]
for (ind, val) in enumerate(elements):
	count_dict[val] = ind
new_list = sorted(count_dict.items(), key=lambda item: item[1])
print(len(new_list))
for item in new_list:
	print(item[0], end=' ')


n = int(input())
l = list(input().split(' '))[::-1]
p = []
for i in range(n):
	if l[i] not in p:
		p.append(l[i])
print(len(p))
print(' '.join(p[::-1]))


n = int(input())
a = list(map(int, input().split()))
stack = []
j = n - 1
while j >= 0:
	if a[j] in stack:
		pass
	else:
		stack.append(a[j])
	j -= 1
print(len(stack))
while len(stack) > 0:
	print(stack.pop(), end=' ')


from collections import Counter
n = int(input())
A = list(map(int, input().split()))
cnt = Counter(A)
app = [0] * (max(A) + 1)
ans = []
for a in A:
	app[a] += 1
	if app[a] == cnt[a]:
		ans.append(a)
print(len(ans))
print(*ans)


import sys

def read_from_stdin():
	N = input()
	array = input().split()
	return [int(i) for i in array]

def write_to_stdout(res):
	sys.stdout.write('%d\n%s\n' % (len(res), ' '.join([str(i) for i in res])))

def get_answer(array):
	rep = set([])
	ans = []
	for item in array:
		if item not in rep:
			rep.add(item)
			ans.append(item)
	return list(reversed(ans))

def main():
	array = read_from_stdin()
	write_to_stdout(get_answer(reversed(array)))
main()


n = int(input())
arr = list(map(int, input().split()))
uniq = set(arr)
arr = arr[::-1]
d = {}
for i in uniq:
	d[i] = arr.index(i)
ans = []
a = sorted(d.items(), key=lambda x: x[1], reverse=True)
for i in range(len(a)):
	ans.append(a[i][0])
print(len(ans))
print(*ans)


n = int(input())
a = list(map(int, input().split()))
x = []
for i in range(len(a) - 1, -1, -1):
	for j in range(0, len(x), 1):
		if x[j] == a[i]:
			break
	else:
		x.append(a[i])
print(len(x))
for i in range(len(x) - 1, -1, -1):
	print(x[i], end=' ')


def main():
	input()
	numbers = [int(num) for num in input().strip().split(' ')]
	entries = set()
	res = []
	for number in reversed(numbers):
		if number not in entries:
			res.append(number)
			entries.add(number)
	print(len(res))
	print(' '.join((str(num) for num in reversed(res))))
main()


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')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
from math import *
from itertools import *
from collections import Counter
from bisect import *

def aa():
	return int(input())

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

def cc():
	s = input()
	return list(s)

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

def koi_coding_sikha_do():
	n = aa()
	arr = bb()
	d = set()
	ans = []
	for i in range(n - 1, -1, -1):
		if arr[i] not in d:
			ans.insert(0, arr[i])
			d.add(arr[i])
	print(len(ans))
	print(*ans)
t = 1
while t:
	koi_coding_sikha_do()
	t -= 1


n = int(input())
elementos = input().split()
i = len(elementos) - 1
while i > -1:
	for j in range(i - 1, -1, -1):
		if elementos[i] == elementos[j]:
			elementos.pop(j)
			i -= 1
	i -= 1
print(len(elementos))
print(*elementos)


n = int(input())
arr = list(map(int, input().split()))
arr1 = []
for i in range(n - 1, -1, -1):
	if arr[i] in arr1:
		pass
	else:
		arr1.append(arr[i])
print(len(arr1))
print(*arr1[::-1])


n = int(input())
x = [int(x) for x in input().split()]
k = 0
while k < len(x):
	if x.count(x[k]) > 1:
		x.pop(k)
		n -= 1
	else:
		k += 1
print(n)
for i in x:
	print(i, end=' ')


n = int(input())
Arr = [int(x) for x in input().split()]
res = []
for i in reversed(Arr):
	if i not in res:
		res.append(i)
print(len(res))
res = reversed(res)
print(*res)


input()
a = input().split()
b = set(a)
c = []
for i in a[::-1]:
	if i in b:
		c.insert(0, i)
		b.remove(i)
print(len(c))
print(' '.join(c))


import math
from collections import *
import sys
from functools import reduce

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

def get_list():
	return list(get_ints())

def get_string():
	return list(input().strip().split())

def printxsp(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')
DIRECTIONS = [[0, 1], [0, -1], [1, 0], [1, -1]]
NEIGHBOURS = [(i, j) for i in range(-1, 2) for j in range(-1, 2) if i != 0 or j != 0]
OrdUnicode_a = ord('a')
OrdUnicode_A = ord('A')
CAPS_ALPHABETS = {chr(i + OrdUnicode_A): i for i in range(26)}
SMOL_ALPHABETS = {chr(i + OrdUnicode_a): i for i in range(26)}
UGLYMOD = int(1000000000.0) + 7
SEXYMOD = 998244353
MAXN = int(100000.0) + 1
INFINITY = float('inf')
N = int(input())
li = get_list()
d = {}
for i in range(N):
	d[li[i]] = i
print(len(d))
for (k, v) in sorted(d.items(), key=lambda x: x[1]):
	printsp(k)


n = int(input().strip())
lst = input().strip().split()
length = len(set(lst))
for i in range(n):
	if lst[i] in lst[i + 1:]:
		lst[i] = ''
print(length)
for i in lst:
	if i.isdigit():
		print(i, end=' ')


def do():
	n = int(input())
	dat = list(map(int, input().split()))
	dat.reverse()
	d = dict()
	res = []
	for i in range(n):
		if dat[i] not in d:
			res.append(dat[i])
			d[dat[i]] = True
	res.reverse()
	print(len(res))
	print(' '.join(list(map(str, res))))
do()

def resolve():
	from pprint import pprint
	q = int(input())
	for _ in range(q):
		s = input()
		n = int(input())
		(n, k) = map(int, input().split())
		dat = list(map(int, input().split()))
	dat = [1, 2, 3]
	print(' '.join(list(map(str, res))))
	pass
	import math
	math.ceil(1.2)
	math.floor(1.2)
	round(1.2, 3)


a = input()
b = list(map(int, input().split()))
b.reverse()
done = []
e = []
for i in b:
	if i not in e:
		e.append(i)
e.reverse()
print(len(e))
for i in e:
	print(i, end='')
	if i != e[-1]:
		print(' ', end='')


n = int(input())
arr = list(map(int, input().split()))
arr1 = []
j = 0
for i in reversed(range(n)):
	a = arr[i]
	if a not in arr1:
		j = j + 1
		arr1.append(a)
print(j)
for j in reversed(range(j)):
	print(arr1[j], end=' ')


n = int(input())
l = [int(x) for x in input().split(' ')]
l = l[::-1]
ans = []
for i in l:
	if i in ans:
		continue
	else:
		ans.append(i)
ans = ans[::-1]
print(len(ans))
print(*ans)


import sys
n = int(input())
a = list(input().split(' '))
b = []
for i in range(n - 1, -1, -1):
	if a[i] not in b:
		b.insert(0, a[i])
print(len(b))
for x in b:
	print(x, end=' ')


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

def read_int():
	return read_ints()[0]
n = read_int()
nums = read_ints()
res = set(nums)
print(len(res))
for (i, val) in enumerate(nums):
	if val in nums[i + 1:]:
		continue
	print(val, end=' ')


import math
dic = {}
n = int(input())
arr = list(map(int, input().split()))
for i in arr:
	try:
		dic[i] += 1
	except:
		dic[i] = 1
ans = []
for i in arr:
	if dic[i] == 1:
		ans.append(i)
	else:
		dic[i] -= 1
print(len(ans))
print(*ans)


t = int(input())
l = list(map(int, input().split()))
k = []
for i in range(t - 1, -1, -1):
	if l[i] in k:
		continue
	else:
		k.append(l[i])
k.reverse()
print(len(k))
print(*k)


n = int(input())
mylist = list(map(int, input().split()))
mylist.reverse()
mylist = list(dict.fromkeys(mylist))
mylist.reverse()
print(len(mylist))
print(*mylist)


n = int(input())
l = list(map(int, input().split()))
z = []
l = l[::-1]
for i in l:
	if i in z:
		continue
	z.append(i)
print(len(z))
print(*z[::-1])


n = int(input())
a = list(map(int, input().split()))
k = set(a)
i = 0
while len(a) != len(k):
	if a.count(a[i]) > 1:
		a.remove(a[i])
	else:
		i += 1
print(len(a))
print(*a)


input()
a = list(map(int, input().split()))
w = [0] * 1001
for i in range(len(a) - 1, -1, -1):
	x = a[i]
	if w[x] > 0:
		a.pop(i)
	else:
		w[x] = 1
print(len(a))
print(*a)


import collections
import logging
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
logger.addHandler(ch)

def solve(n, arr):
	dq = collections.deque()
	v = set()
	for i in reversed(arr):
		if i in v:
			continue
		v.add(i)
		dq.appendleft(i)
	return dq

def main():
	n = int(input().strip())
	arr = input().strip().split()
	result = solve(n, arr)
	print(len(result))
	print(' '.join(result))
main()


n = int(input())
arr = [int(num) for num in input().split()]
arr1 = arr.copy()
for i in arr1:
	if arr.count(i) > 1:
		for k in range(arr.count(i) - 1):
			arr.remove(i)
print(len(arr))
for i in arr:
	print(i, end=' ')


num_input = int(input())
a = input().split(' ')
b = []
count = 0
if num_input == len(a):
	for i in range(len(a) - 1, -1, -1):
		if len(b) == 0:
			b.insert(0, int(a[i]))
		elif int(a[i]) in b:
			continue
		else:
			b.insert(0, int(a[i]))
	s = ''
	for j in b:
		count += 1
		s += str(j) + ' '
	print(count)
	print(s)


n = int(input())
a = list(map(int, input().split()))
a.reverse()
l = []
d = {}
for i in a:
	if i not in d:
		l.append(str(i))
		d[i] = 1
print(len(l))
l.reverse()
print(' '.join(l))


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(-1, -n - 1, -1):
	if a[i] not in b:
		b.append(a[i])
b = b[::-1]
print(len(b))
print(*b)


size_a = int(input())
a = [i for i in input().split()]
b = ['a']
size_b = 1
i = j = 0
while i < size_a:
	j = i + 1
	while j < size_a:
		if a[i] == a[j]:
			k = 0
			chek = 0
			while k < size_b:
				if a[i] == b[k]:
					chek = 1
				k += 1
			if chek == 0:
				b.append(a[i])
				size_b += 1
		j += 1
	i += 1
i = 1
j = 0
zero = ''
deel = 0
while i < size_b:
	j = 0
	f = a.count(b[i])
	while j < f - 1:
		c = a.index(b[i])
		a[c] = zero
		deel += 1
		j += 1
	i += 1
i = 0
print(len(a) - deel)
while i < len(a):
	if a[i] != '':
		print(a[i], end=' ')
	i += 1


n = int(input().strip())
arr = list(map(int, input().split()))
visited = [0] * 2000
count = 0
for i in range(n - 1, -1, -1):
	data = arr[i]
	if visited[data] == 0:
		visited[data] = 1
		count += 1
	elif visited[data] == 1:
		arr[i] = 0
print(count)
for i in range(n):
	if arr[i]:
		print(arr[i], end=' ')


a = int(input())
b = list(input().split(' '))
c = b[::-1]
print(len(set(b)))
for i in set(b):
	k = c.index(i)
	for j in range(k + 1, len(c)):
		if c[j] == i:
			c[j] = 'k'
for i in c[::-1]:
	if i != 'k':
		print(i, end=' ')


def answer():
	n = int(input())
	a = [int(x) for x in input().split()]
	c = []
	a.reverse()
	for x in a:
		if x not in c:
			c.append(x)
	i = 0
	ans = ''
	c.reverse()
	print(len(c))
	while i < len(c):
		ans += str(c[i])
		i += 1
		if i != len(c):
			ans += ' '
	return ans
print(answer())


a = int(input())
d = {}
s = input().strip().split()[:a]
j = []
s.reverse()
for x in s:
	if x in d:
		d[x] += 1
	else:
		d[x] = 1
for x in d:
	j.append(x)
print(len(d))
j.reverse()
print(' '.join(map(str, j)))


n = int(input())
a = [int(k) for k in input().split()]
a = list(a)
sum = 0
for i in range(len(a) - 1, -1, -1):
	for j in range(0, i):
		if a[i] == a[j]:
			a[j] = -1
for i in range(0, len(a)):
	if a[i] != -1:
		sum += 1
print(sum)
for i in range(0, len(a)):
	if a[i] != -1:
		print(a[i], end=' ')
print()


n = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(n):
	f = list(filter(lambda x: a[i] == x, a))
	if len(f) == 1:
		ans.append(a[i])
	else:
		a[i] = -1
print(len(ans))
print(*ans)


def A978(n, arr):
	temp = [arr[-1]]
	for v in arr[::-1]:
		if v not in temp:
			temp.append(v)
	return temp[::-1]
n = int(input())
arr = list(map(int, input().split(' ')))
result = A978(n, arr)
print(len(result))
print(*result)


n = int(input())
l = list(map(int, input().split()))
d = {}
for i in range(n):
	if l[i] not in d:
		d[l[i]] = 0
	else:
		d[l[i]] += 1
for i in d.keys():
	for j in range(d[i]):
		l.remove(i)
print(len(l))
for i in range(len(l)):
	print(l[i], end=' ')


n = int(input())
a = [int(x) for x in input().split()]
i = 0
l = n
positions = [-1] * 1001
while i < n:
	x = a[i]
	pos = positions[x]
	if pos != -1:
		a[pos] = -1
		l -= 1
	positions[x] = i
	i += 1
print(l)
i = 0
while i < n:
	x = a[i]
	if x != -1:
		print(x, end=' ')
	i += 1


from collections import deque

def get_res(N, L):
	S = set()
	Z = deque()
	for i in range(N - 1, -1, -1):
		x = L[i]
		if x not in S:
			Z.appendleft(x)
			S.add(x)
	Zl = list(Z)
	print(len(Zl))
	s = ' '.join(Zl)
	return s
N = int(input())
L = [s for s in input().split(' ')]
result = get_res(N, L)
print('{}'.format(result))


z = input
from math import *
z()
nl = []
l = list(map(int, z().split()))
for i in l[::-1]:
	if i not in nl:
		nl.append(i)
print(len(nl))
print(*nl[::-1])


n = input()
nums = reversed(input().split())
result = []
for i in nums:
	if i not in result:
		result.append(i)
print('%d' % len(result))
print(' '.join(reversed(result)))


import operator
n = int(input())
array = [int(x) for x in input().split(' ')]
d = {}
for i in range(n):
	d[array[i]] = i
sorted_d = sorted(d.items(), key=operator.itemgetter(1))
print(len(sorted_d))
print(' '.join((str(x[0]) for x in sorted_d)))


n = int(input())
a = list(map(int, input().split()))
se = []
for i in range(n - 1, -1, -1):
	if a[i] in se:
		continue
	else:
		se.append(a[i])
print(len(se))
for i in se[::-1]:
	print(i, end=' ')


n = int(input())
spisok = list(map(int, input().split()))
ans = []
for i in range(len(spisok)):
	if spisok[i] in ans:
		ans.remove(spisok[i])
	ans.append(spisok[i])
print(len(ans))
print(' '.join(map(str, ans)))


n = input()
x = [int(x) for x in input().split()]
x.reverse()
l = []
for i in x:
	if i not in l:
		l.append(i)
print(len(l))
l.reverse()
for i in l:
	print(str(i), end=' ')


n = int(input())
l = list(map(int, input().split()))
d = {}
p = l[::-1]
for i in p:
	if i in d:
		l.remove(i)
	else:
		d[i] = 1
x = len(l)
print(x)
for i in l:
	print(i, end=' ')
print()


n = int(input())
f = [0] * 1005
l = [int(x) for x in input().split()]
for i in range(n):
	f[l[i]] = i
ans = []
for i in range(n):
	if i == f[l[i]]:
		ans.append(l[i])
print(len(ans))
print(*ans)


n = int(input())
s = list(map(int, input().split()))
l = []
i = len(s) - 1
while i >= 0:
	if s[i] not in l:
		l = l + [s[i]]
	i = i - 1
ns = ''
l.reverse()
for i in l:
	ns = ns + str(i) + ' '
print(len(l))
print(ns)


n = int(input())
s = input().split()
a = []
while 1:
	if s[0] in s[1:]:
		del s[0]
	else:
		a.append(s[0])
		del s[0]
	if len(s) == 0:
		break
print(len(a))
print(' '.join(a))


n = int(input())
data = [int(i) for i in input().split()]
was = []
for elem in data[::-1]:
	if elem not in was:
		was.append(elem)
print(len(was))
print(*was[::-1])


R = lambda : map(int, input().split())
input()
n = list(R())
b = []
for a in reversed(n):
	if a not in b:
		b.append(a)
b = list(map(str, b))
print(len(b))
print(' '.join(reversed(b)))


t = int(input())
a = list(map(int, input().split()))
b = [0] * 1001
for i in range(t):
	b[a[i]] += 1
c = []
for i in range(t):
	if a[t - i - 1] not in c and b[a[t - i - 1]] > 0:
		c.append(a[t - i - 1])
c = c[::-1]
l = len(c)
print(l)
for i in range(l):
	print(c[i], end=' ')


n = input()
s = list(map(int, input().split()))
c = [0] * len(s)
ans = []
for i in range(0, len(s)):
	c[i] = s[len(s) - 1 - i]
for i in range(0, len(c)):
	if c[i] not in ans:
		ans.append(c[i])
print(len(ans))
finalans = [0] * len(ans)
for i in range(0, len(ans)):
	finalans[i] = ans[len(ans) - 1 - i]
	print(finalans[i], end=' ')


_ = input()
a = list(map(int, input().split()))
r = []
for i in range(len(a) - 1, -1, -1):
	if a[i] not in r:
		r.append(a[i])
print(len(r))
print(' '.join(map(str, r[::-1])))


size = int(input())
lst = [int(i) for i in input().split()]
d = {}
ind = 0
for i in lst:
	d[i] = ind
	ind = ind + 1
print(len(d.keys()))
indexes = sorted(d.values())
for i in indexes:
	print(lst[i], end=' ')


n = int(input())
l = list(map(int, input().split()))
s = set(l)
l1 = []
l2 = []
a = 0
for i in s:
	for j in range(len(l)):
		if i == l[j]:
			a = j
	l1.append(a)
l1.sort()
for i in l1:
	l2.append(l[i])
print(len(s))
print(*l2)


n = int(input())
L = list(map(int, input().split()))
S = []
for i in L:
	S += [i]
for i in L:
	while S.count(i) > 1:
		S.remove(i)
print(len(S))
for i in S:
	print(i, end=' ')


n = int(input())
l = list(map(int, input().split()))
s = [l[n - 1]]
for i in range(2, n + 1):
	if l[-i] not in l[n - i + 1:n]:
		s.append(l[-i])
s.reverse()
print(len(s))
for j in s:
	print(j, end=' ')


l = input()
a = input()
a = a.split()
a = a[::-1]
b = []
for i in range(len(a)):
	if a[i] not in b:
		b.insert(0, a[i])
print(len(b))
for i in range(len(b)):
	print(b[i], end=' ')


int(input())
s = list(map(int, input().split()))
ans = []
for i in s[::-1]:
	if i not in ans:
		ans.append(i)
print(len(ans))
print(*ans[::-1])


n = int(input())
s = input()
list1 = s.split()
list2 = []
for i in list1:
	if i in list2:
		list2.remove(i)
		list2.append(i)
	if i not in list2:
		list2.append(i)
print(len(list2))
for i in list2:
	print(int(i), end=' ')


n = int(input())
arr = list(map(int, input().split()))
j = n - 1
count = 0
temp = []
while j >= 0:
	if not arr[j] in temp:
		temp.append(arr[j])
		count += 1
	else:
		pass
	j -= 1
print(count)
for i in range(count):
	print(temp.pop(), end=' ')


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_int = lambda : int(sys.stdin.readline().strip())
pt = lambda x: sys.stdout.write(str(x))
n = get_int()
array = get_list()[::-1]
l = []
for i in array:
	if i not in l:
		l.append(i)
print(len(l))
print(*l[::-1])


n = int(input())
a = list(map(int, input().split()))
lis = []
uni = list(set(a))
new = len(uni)
for i in range(n):
	for j in range(new):
		if a[n - 1 - i] == uni[j]:
			lis.append(a[n - 1 - i])
			uni[j] = 0
qw = lis[::-1]
print(new)
print(*qw)


import sys
from math import sqrt, floor, factorial
from collections import deque, Counter
inp = sys.stdin.readline
read = lambda : list(map(int, inp().strip().split()))

def solve():
	n = int(inp())
	arr = read()
	sett = set()
	ans = deque()
	for i in range(-1, -n - 1, -1):
		if not arr[i] in sett:
			sett.add(arr[i])
			ans.appendleft(arr[i])
	print(len(ans))
	print(*ans)
solve()


n = int(input())
my_list = list(map(int, input().split()))
answer_list = []
for i in range(n - 1, -1, -1):
	if my_list[i] not in answer_list:
		answer_list.append(my_list[i])
print(len(answer_list))
print(*reversed(answer_list))


n = int(input())
s = input().split()
mat = []
for i in range(n - 1, -1, -1):
	if not s[i] in mat:
		mat.append(s[i])
print(len(mat))
print(*mat[::-1])


n = int(input())
a = list(map(int, input().split()))
d = 1001 * [0]
ans = []
for t in range(n):
	d[a[t]] = 1
a.reverse()
for t in range(n):
	if d[a[t]] == 1:
		ans.append(a[t])
		d[a[t]] = 0
ans.reverse()
print(len(ans))
print(' '.join(map(str, ans)))


def solve(test):
	n = int(input())
	ans = []
	a = list(map(int, input().split()))
	for i in range(n - 1, -1, -1):
		if a[i] not in ans:
			ans.append(a[i])
	print(len(ans))
	print(*ans[::-1])
t = 1
for _ in range(t):
	solve(_ + 1)


n = int(input())
b = []
for i in list(map(int, input().split())):
	if i in b:
		b.pop(b.index(i))
	b.append(i)
print(len(b))
print(*b)


n = int(input())
a = list(map(int, input().split()))
a.reverse()
r = []
for i in range(n):
	if not a[i] in r:
		r.append(a[i])
r.reverse()
print(len(r))
print(' '.join(map(str, r)))


from math import *
from cmath import *
from itertools import *
from decimal import *
from fractions import *
from sys import *
from types import CodeType, new_class
n = int(input())
d = [0] * 1005
a = [int(x) for x in input().split()]
a.reverse()
b = []
for x in a:
	if d[x] == 0:
		b.append(x)
	d[x] += 1
print(len(b))
b.reverse()
print(*b)


am = int(input())
arr = list(map(int, input().split()))
was = [False] * 1001
out = []
for i in range(am - 1, -1, -1):
	if not was[arr[i]]:
		was[arr[i]] = True
		out.append(arr[i])
print(len(out))
print(*reversed(out))


n = int(input())
arr = [int(x) for x in input().split()]
s = []
for i in range(n):
	if arr[i] in s:
		a = s.index(arr[i])
		del s[a]
		s.append(arr[i])
	else:
		s.append(arr[i])
print(len(s))
print(*s)


def main():
	n = input()
	arr = [int(t) for t in input().split()]
	s = set(arr)
	index = [[1001, 1001] for _ in range(1001)]
	for t in range(len(arr)):
		index[arr[t]][0] = arr[t]
		index[arr[t]][1] = t
	index.sort(reverse=False, key=lambda x: x[1])
	print(len(s))
	for item in index:
		if item[0] > 1000:
			break
		print(item[0], end=' ')
	print()
main()


n = int(input())
a = [int(i) for i in input().split()]
d = {}
for i in range(n - 1, -1, -1):
	if a[i] not in d.keys():
		d[a[i]] = 1
print(len(d.keys()))
print(' '.join([str(i) for i in list(d.keys())[::-1]]))


n = int(input())
temparr = input()
temparr = temparr.split()
arr = []
dicts = {}
index = 0
for i in temparr:
	arr.append(i)
	if i not in dicts:
		dicts[i] = []
	dicts[i].append(index)
	index += 1
resultarr = []
for (key, value) in dicts.items():
	mostright = value[-1]
	resultarr.append((mostright, key))
ans = sorted(resultarr)
ansstring = ''
for item in ans:
	ansstring += item[1]
	ansstring += ' '
print(len(dicts))
print(ansstring[:-1])


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	p = list(map(int, input().split()))
	s = set()
	ans = []
	u = p[::-1]
	for (i, pi) in enumerate(u):
		if pi not in s:
			s.add(pi)
			ans.append(pi)
	print(len(ans))
	print(*ans[::-1])
main()


a = int(input())
b = input()
b = [int(s) for s in b.split()]
b.reverse()
s = []
for i in b:
	if i not in s:
		s.append(i)
print(len(s))
s.reverse()
s = ' '.join((str(item) for item in s))
print(s)


n = int(input())
a = [int(i) for i in input().split()]
dic = {}
for i in range(n):
	if a[i] in dic.keys():
		dic[a[i]] += 1
	else:
		dic[a[i]] = 1
j = 0
for i in range(n):
	if dic[a[j]] > 1:
		dic[a[j]] -= 1
		a.pop(j)
	else:
		j += 1
	if j == len(a):
		break
print(len(a))
for i in range(len(a)):
	print(a[i], end=' ')


n = int(input())
arr = list(map(int, input().split()))
mp = [int(-1)] * 1001
for i in range(0, n):
	mp[arr[i]] = i
res = []
for i in range(0, n):
	for j in range(0, 1001):
		if mp[j] == i:
			res.append(j)
			break
print(len(res))
print(*res)


input()
N = list(map(int, input().split()))
J = len(N) - 1
I = 0
while J > 0:
	I = 0
	while I != J:
		if N[I] == N[J]:
			N.remove(N[I])
			J -= 1
		else:
			I += 1
	J -= 1
print(len(N))
print(*N)


import sys
import math
from functools import reduce
import bisect

def getN():
	return int(input())

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

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

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

def index(a, x):
	i = bisect.bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	return -1
n = getN()
arr = getList()
check = [0] * 1002
new = []
arr = arr[::-1]
for i in arr:
	if check[i] == 0:
		new.append(i)
		check[i] += 1
new = new[::-1]
print(len(new))
print(*new)


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

def main():
	s = set()
	GI()
	l = [s.add(x) or x for x in reversed(LGIS()) if x not in s]
	l.reverse()
	print(len(l))
	print(' '.join(map(str, l)))
main()


n = int(input())
a = input().split()
b = []
for i in range(n - 1, -1, -1):
	a[i] = int(a[i])
	true = True
	for j in range(len(b)):
		if a[i] == b[j]:
			true = False
			break
	if true:
		b = [a[i]] + b
print(len(b))
for i in range(len(b)):
	print(b[i], end=' ')


n = int(input())
li = [0 for i in range(1001)]
v = [int(i) for i in input().split()]
r = []
for i in range(n - 1, -1, -1):
	if li[v[i]] == 0:
		r.append(v[i])
	li[v[i]] += 1
print(len(r))
print(*reversed(r))


def solve(n, ai):
	ai.reverse()
	s = set()
	a_res = list()
	for a in ai:
		if a not in s:
			a_res.append(a)
			s.add(a)
	a_res.reverse()
	l = len(a_res)
	return (l, a_res)
n = int(input())
ai = [int(s) for s in input().split(' ')]
(l, a_res) = solve(n, ai)
print(l)
print('%s' % ' '.join(map(str, a_res)))


n = int(input())
lis = list(map(int, input().split()))
flis = []
for i in lis[::-1]:
	if i not in flis:
		flis.append(i)
print(len(flis))
for i in flis[::-1]:
	print(i, end=' ')


n = int(input())
s = input().split()[::-1]
te = [False for i in range(1000)]
ans = []
for i in s:
	if te[int(i) - 1] == False:
		ans.append(i)
	te[int(i) - 1] = True
print(len(ans))
print(' '.join(ans[::-1]))


ll = input()
ll = input().split()
t = 0
for i in range(len(ll)):
	if ll.count(ll[i - t]) > 1:
		del ll[i - t]
		t += 1
print(len(ll))
print(' '.join(ll))


from sys import stdout

def unique(_list, n):
	aux = set()
	result = []
	_list = _list[::-1]
	for each in _list:
		if each not in result:
			aux.add(each)
			result += [each]
	return result[::-1]
n = int(input())
un = unique(input().split(' '), n)
print(len(un))
for elem in un:
	stdout.write(elem + ' ')
print()


siz = int(input())
arr = list(map(int, input().split()))
arr.reverse()
unq = []
for i in range(0, siz):
	if arr[i] not in unq:
		unq.append(arr[i])
print(len(unq))
unq.reverse()
ing = ' '.join(map(str, unq))
print(ing)


def main():
	N = int(input())
	A = tuple(map(int, input().split()))
	ans = []
	for i in A[::-1]:
		if i not in ans:
			ans.append(i)
	print(len(ans))
	print(*ans[::-1])
main()


n = input()
s = set()
lis = [int(x) for x in input().split()]
i = len(lis) - 1
while i >= 0:
	if lis[i] in s:
		lis[i] = None
	else:
		s.add(lis[i])
	i -= 1
print(len(s))
for x in lis:
	if x == None:
		continue
	else:
		print(x, end=' ')
print()


n = int(input())
sr = input()
sr = sr.split()
sr = sr[::-1]
final = list()
for i in sr:
	i = int(i)
	if i not in final:
		final.append(i)
count = 0
for i in final:
	count = count + 1
print(count)
final.reverse()
for i in final:
	print(i, end=' ')


n = int(input())
l = [int(i) for i in input().split()]
c = []
for k in range(len(l) - 1, -1, -1):
	if l[k] not in c:
		c.append(l[k])
print(len(c))
c = c[::-1]
print(*c)


n = int(input())
arr = list(map(int, input().split()))
arr2 = [False for i in range(len(arr))]
arr3 = []
for i in range(len(arr) - 1, -1, -1):
	if arr2[i] == False:
		arr3.insert(0, arr[i])
	arr2[i] = True
	for j in range(i):
		if arr[j] == arr[i]:
			arr2[j] = True
print(len(arr3))
for i in range(len(arr3)):
	print(arr3[i], end=' ')
print()


n = int(input())
a = [int(x) for x in input().split()]
res = []
for v in reversed(a):
	if res.count(v) == 0:
		res.append(v)
print(len(res))
print(' '.join((str(x) for x in reversed(res))))


n = input()
n = int(n)
ary = list(map(int, input().split()))
f = []
for x in ary[::-1]:
	if x in f:
		f.append(x)
		ary.remove(x)
	else:
		f.append(x)
print(len(ary))
res = ''
for (k, x) in enumerate(ary):
	if k:
		res += ' '
	res += str(x)
print(res)


n = int(input())
a = []
a = list(map(int, input().split()))
s = []
i = 0
while i < len(a) - 1:
	z = a[i + 1:]
	if a[i] in z:
		a.pop(i)
	else:
		s.append(a[i])
		i += 1
s.append(a[len(a) - 1])
print(len(s))
for i in range(len(s)):
	print(s[i], end=' ')
print()


def main():
	_ = int(input())
	A = [int(i) for i in input().split()]
	S = set()
	ans = []
	for a in A[::-1]:
		if a not in S:
			ans.append(a)
			S.add(a)
	print(len(ans))
	print(*ans[::-1])
main()


n = int(input())
a = input()
a = [int(x) for x in a.split(' ')]
povt = []
res = []
for el in reversed(a):
	if el in povt:
		continue
	else:
		res = [el] + res
		povt.append(el)
print(len(res))
res = [str(el) for el in res]
print(' '.join(res))


n = int(input())
a = []
c = []
a = [int(x) for x in input().split()]
a.reverse()
max = 0
for i in a:
	if i > max:
		max = i
b = [0] * (max + 1)
for i in a:
	if b[i] == 0:
		c.append(i)
		b[i] += 1
c.reverse()
print(len(c))
for i in c:
	print(i, end=' ')


n = int(input())
ls = [int(i) for i in input().split()]
ls.reverse()
ans = [-1] * n
dic = {i: n - 1 - ls.index(i) for i in set(ls)}
for i in dic.keys():
	ans[dic[i]] = i
print(len(dic))
for i in ans:
	print(i, end=' ') if i != -1 else 1


x = int(input())
a = [int(i) for i in input().split()]
l = []
l += a
d = 0
for i in a:
	if l.count(i) > 1:
		l.remove(i)
		d += 1
print(len(l))
print(*l)


N = input()
arr = input().split()
arr = arr[::-1]
output = []
for (i, c) in enumerate(arr):
	if c not in output:
		output.append(c)
print(len(output))
output = output[::-1]
print(' '.join((c for c in output)))


z = input
mod = 10 ** 9 + 7
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0:
			return 0
	return 1
z = input
n = int(z())
l = list(map(int, z().split()))[::-1]
nl = []
print(len(set(l)))
for i in l:
	if i not in nl:
		nl.append(i)
print(*nl[::-1])


n = int(input())
d = list(map(str, input().split()))
sol = []
for i in d[::-1]:
	if i not in sol:
		sol.append(i)
print(len(sol))
print(' '.join(list(map(str, sol[::-1]))))


n = int(input())
arr = [int(i) for i in input().strip().split()]
d = {}
a = []
for i in range(1, len(arr) + 1):
	if str(arr[-i]) not in d:
		d[str(arr[-i])] = 1
		a.append(arr[-i])
print(len(a))
for i in range(1, len(a) + 1):
	print(a[-i], end=' ')


n = int(input())
L = list(map(int, input().split()))
Ans = []
for i in range(1, len(L) + 1):
	if L[-i] not in Ans:
		Ans.append(L[-i])
Ans = Ans[::-1]
print(len(Ans))
print(*Ans)


s = int(input())
a = input()
a = a.split()
num = []
for x in a[::-1]:
	if x not in num:
		num.append(x)
num = num[::-1]
print(len(num))
print(' '.join(num))


n = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(len(a)):
	try:
		a[i + 1:len(a)].index(a[i])
	except:
		ans.append(a[i])
print(len(ans))
for i in ans:
	print(i, end=' ')


n = int(input())
num = list(map(int, input().split()))
i = n - 1
while i >= 0:
	cek = num[i]
	if cek != -1:
		for j in range(i):
			if num[j] == cek:
				num[j] = -1
				n -= 1
	i -= 1
print(n)
for i in range(len(num) - n):
	num.remove(-1)
res = ''
for i in range(len(num)):
	res += str(num[i]) + ' '
print(res.strip())


n = int(input())
a = list(map(int, input().split()))
c = 0
l = a[:]
for i in a:
	if l.count(i) > 1:
		l.remove(i)
	else:
		pass
print(len(l))
print(*l)


n = int(input())
a = list(map(int, input().split()))
b = list()
s = set()
for i in range(n):
	if a[n - i - 1] in s:
		continue
	else:
		s.add(a[n - i - 1])
		b.insert(0, a[n - i - 1])
print(len(s))
print(*b)


import operator
n = int(input())
a = [int(x) for x in input().split()]
d = {}
for i in range(n):
	d[a[i]] = i
l = len(set(a))
d_ = dict(sorted(d.items(), key=operator.itemgetter(1)))
print(len(d_))
for i in d_:
	print(i, end=' ')


n = int(input())
a = [int(i) for i in input().split()]
b = []
for i in range(n - 1, -1, -1):
	for j in range(n - 1, -1, -1):
		if a[i] == a[j] and i != j:
			a[j] = 0
	if a[i] != 0:
		b.append(a[i])
	a[i] = 0
b = b[::-1]
print(len(b))
print(*b)


r = int(input())
a = list(map(int, input().split()))
b = []
for i in a[r - 1:0:-1]:
	if i not in b:
		b.append(i)
if a[0] not in b:
	b.append(a[0])
print(len(b))
for i in range(len(b) - 1, -1, -1):
	print(b[i], end=' ')


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
n = int(z())
l = zzz()
lst = []
for i in range(1, n + 1):
	if l[-i] not in lst:
		lst.append(l[-i])
print(len(lst))
print(*lst[::-1])


n = int(input())
l = [int(i) for i in input().split()]
l = l[::-1]
ans = []
been = set()
for i in range(len(l)):
	if l[i] not in been:
		been.add(l[i])
		ans += [l[i]]
print(len(ans))
print(*ans[::-1])


def rem(A):
	lista = []
	tam = len(A)
	for e in A:
		if e not in lista:
			lista.append(e)
		else:
			lista.remove(e)
			tam -= 1
			lista.append(e)
	print(tam)
	return lista
nA = int(input())
A = [int(x) for x in input().split()]
print(*rem(A))


from sys import stdin

def solve(tc):
	n = int(stdin.readline().strip())
	li = list(map(int, stdin.readline().split()))
	vis = [0 for i in range(1001)]
	res = []
	for i in range(n):
		if vis[li[n - 1 - i]] == 0:
			res.insert(0, li[n - 1 - i])
			vis[li[n - 1 - i]] = 1
	print(len(res))
	for i in range(len(res)):
		print(res[i], end=' ')
	print()
	pass
LOCAL_TEST = not __debug__
if LOCAL_TEST:
	infile = __file__.split('.')[0] + '-test.in'
	stdin = open(infile, 'r')
tcs = int(stdin.readline().strip()) if LOCAL_TEST else 1
tc = 1
while tc <= tcs:
	solve(tc)
	tc += 1


n = int(input())
a = [int(q) for q in input().strip().split()]
b = list(set(a))
c = []
a = a[::-1]
for k in range(len(a)):
	if a[k] in b:
		c.append(a[k])
		b.remove(a[k])
		if len(b) == 0:
			break
c = c[::-1]
for k in range(len(c)):
	c[k] = str(c[k])
print(len(c))
print(' '.join(c))


n = int(input())
l = list(map(int, input().split()))
for i in range(n - 1, -1, -1):
	for j in range(i):
		if l[i] == l[j]:
			l[j] = -1
c = 0
for i in range(n):
	if l[i] != -1:
		c += 1
print(c)
for i in range(n):
	if l[i] != -1:
		print(l[i], end=' ')


from sys import stdin, stdout
import bisect
import math

def st():
	return list(stdin.readline())

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

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

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

def pr(n):
	stdout.write(str(n) + '\n')

def soe(limit):
	l = [1] * (limit + 1)
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
			n = n - 1
		else:
			a = a * a
			n = n >> 1
	return r

def solve():
	n = inp()
	l = li()
	l = l[::-1]
	x = []
	v = []
	for i in l:
		if i not in v:
			x.append(i)
			v.append(i)
	x = x[::-1]
	print(len(x))
	print(*x)
solve()


arr = [int(i) for i in (input().split() + input().split())[1:]][::-1]
print(len(set(arr)))
az = [0] * 1001
ans = []
for i in arr:
	if az[i] == 0:
		az[i] = 1
		ans += [i]
print(' '.join([str(i) for i in ans[::-1]]))


n = int(input())
a = list(map(int, input().split()))[::-1]
d = {}
res = []
for i in a:
	if i in d:
		continue
	d[i] = 1
	res.append(i)
print(len(res))
print(*res[::-1])


n = input()
num = input()
num = num.split()
ans = ''
count = 0
for l in range(int(n)):
	if num[l] in num[l + 1:]:
		continue
	else:
		count = count + 1
		ans = ans + ' ' + num[l]
print(count)
print(ans.lstrip())


n = int(input())
a = list(map(int, input().split()))
aux = []
for i in range(n - 1, -1, -1):
	if a[i] not in aux:
		aux.append(a[i])
aux.reverse()
result = ' '.join((str(x) for x in aux))
print(len(aux))
print(result)


n = int(input())
a = list(map(int, input().split()))
h = [0] * 1003
h = h[:]
ans = []
for i in a[::-1]:
	if h[i] == 0:
		ans.append(i)
		h[i] = 1
print(len(ans))
print(*ans[::-1])


n = int(input())
d = []
for (i, v) in enumerate(map(int, input().split())):
	while v in d:
		d.remove(v)
	d.append(v)
print(len(d))
print(' '.join([str(_) for _ in d]))


t = int(input())
l = list(map(int, input().split()))
s = len(set(l))
for i in range(len(l)):
	if l[i] in l[i + 1:]:
		l[i] = '#'
while len(l) > s:
	l.remove('#')
print(s)
for i in l:
	print(i, end=' ')


a = int(input())
ar = list(map(int, input().split()))
rez = []
for i in ar[::-1]:
	if i not in rez:
		rez.append(i)
print(len(rez))
print(*rez[::-1])


n = int(input())
A = list(map(int, input().split()))
A.reverse()
L = [0] * 1001
out = []
for i in range(n):
	if not L[A[i]]:
		out.append(A[i])
		L[A[i]] = 1
out.reverse()
print(len(out))
for i in out:
	print(i, end=' ')


n = int(input())
a = [int(i) for i in input().split()]
b = [a[0]]
z = 0
for i in range(n - 1, -1, -1):
	for j in range(i):
		if a[j] == a[i]:
			a[j] = -1
	if a[i] != -1:
		z += 1
print(z)
for i in range(n):
	if a[i] != -1:
		print(a[i], end=' ')


import sys

def main():
	n = int(sys.stdin.readline().strip())
	p = list(sys.stdin.readline().split())
	res = []
	for i in range(n):
		if p[i] in res:
			res.remove(p[i])
		res.append(p[i])
	print(len(res))
	print(' '.join(res))
main()


N = int(input())
arr = [int(k) for k in input().split(' ')]
rev = []
for i in arr[::-1]:
	if rev.count(i) == 0:
		rev.append(i)
print(rev.__len__())
for i in rev[::-1]:
	print(i, end=' ')


import sys
mylen = int(sys.stdin.readline())
myline = sys.stdin.readline()
mylist = myline.split()
result = []
for i in range(len(mylist) - 1, -1, -1):
	if mylist[i] not in result:
		result.append(mylist[i])
sys.stdout.write(str(len(result)) + '\n')
for i in range(len(result) - 1, -1, -1):
	sys.stdout.write(result[i] + ' ')


n = input()
l = input().split()
x = []
c = 0
l.reverse()
for i in l:
	if i not in x:
		x.append(i)
		c += 1
print(c)
x.reverse()
print(' '.join(x))


n = int(input())
the_string = [i for i in input().split()]
the_string.reverse()
new_list = []
for i in the_string:
	if i not in new_list:
		new_list.append(i)
new_list.reverse()
print(len(new_list))
for y in new_list:
	print(y, end=' ')


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

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

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

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

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

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

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

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

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

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

def input():
	return sys.stdin.readline().strip()
n = int(input())
Arr = get_array()
myset = set()
result = deque([])
for i in range(n - 1, -1, -1):
	if Arr[i] not in myset:
		result.appendleft(Arr[i])
		myset.add(Arr[i])
result = list(result)
print(len(result))
print(*result, sep=' ')


l = int(input())
n = input().split()
revert = n[::-1]
out = []
for x in range(l):
	i = revert[x]
	if i in out:
		continue
	out.append(i)
print(len(out))
print(' '.join(out[::-1]))


from collections import defaultdict

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

def main():
	input()
	nums = read_nums()
	nums.reverse()
	s = set()
	res = []
	for num in nums:
		if num not in s:
			res.append(num)
			s.add(num)
	res.reverse()
	print(len(res))
	print(' '.join([str(x) for x in res]))
main()


n = int(input())
lista = list(map(int, input().split()))
j = 0
while j < len(lista):
	if lista.count(lista[j]) > 1:
		del lista[j]
	else:
		j += 1
print(len(lista))
print(*lista)


from collections import Counter
n = int(input())
a = [int(x) for x in input().split()]
d = Counter(a)
x = []
for i in range(len(a)):
	if d[a[i]] == 1:
		continue
	else:
		x.append(i)
		d[a[i]] -= 1
print(n - len(x))
for i in range(len(a)):
	if i in x:
		continue
	else:
		print(a[i], end=' ')


n = int(input())
L = list(map(int, input().split()))
a = [L[x] for x in reversed(range(n))]
k = []
for i in a:
	if i not in k:
		k.append(i)
b = [k[x] for x in reversed(range(len(k)))]
print(len(b))
print(*b, sep=' ', end='\n')


n = int(input())
l = list(map(int, input().split()))
a = list(set(l))
k = []
for i in range(n - 1, -1, -1):
	if l[i] in a:
		k.append(l[i])
		a.remove(l[i])
print(len(k))
for i in range(len(k) - 1, -1, -1):
	print(k[i], end=' ')


n = int(input())
l = list(map(int, input().split()))
l.reverse()
l1 = []
for el in l:
	if l1.count(el) == 0:
		l1 += [el]
print(len(l1))
l1.reverse()
print(*l1)


input()
data = list(map(int, input().split()))[::-1]
ti = 0
found = set([data[0]])
for s in data[1:]:
	if s not in found:
		ti += 1
		data[ti] = s
		found.add(s)
print(ti + 1)
print(' '.join(map(str, data[:ti + 1][::-1])))


n = int(input())
p = [-1] * 1010
a = [0] * 55
num = 0
str = input()
a = [int(i) for i in str.split()]
for i in range(n):
	if p[a[i]] == -1:
		num += 1
	p[a[i]] = i
print(num)
for i in range(n):
	if p[a[i]] != -1:
		if p[a[i]] == i:
			print(a[i], end=' ')


n = int(input())
A = list(map(int, input().split()))
heh = []
for z in range(n - 1, -1, -1):
	if A[z] not in heh:
		heh.append(A[z])
heh = heh[::-1]
print(len(heh))
print(' '.join(list(map(str, heh))))


y = int(input())
x = list(map(int, input().split()[:y]))
i = list(reversed(x))
output = []
for j in i:
	if j not in output:
		output.append(j)
k = list(reversed(output))
print(len(output))
print(' '.join(map(str, k)))


n = input()
a = input().split()[::-1]
result = []
for el in a:
	if el not in result:
		result.append(el)
print(len(result))
print(' '.join(result[::-1]))


n = int(input())
l = list(map(int, input().split()))
ans = []
vis = [0] * 1005
for i in range(n - 1, -1, -1):
	if vis[l[i]] == 0:
		ans.append(l[i])
	vis[l[i]] = 1
print(len(ans))
for i in range(len(ans) - 1, -1, -1):
	print(ans[i], end=' ')


try:
	n = int(input())
	a = list(map(int, input().split()))
	rem = [0 for i in range(n)]
	for i in range(n - 1, 0, -1):
		for j in range(i - 1, -1, -1):
			if a[j] == a[i]:
				rem[j] = 1
	coun = 0
	for i in range(n):
		if rem[i] == 0:
			coun += 1
	print(coun)
	for i in range(n):
		if rem[i] == 0:
			print(a[i], end=' ')
	print()
except:
	pass


from sys import stdin, stdout

def rint():
	return map(int, stdin.readline().split())
n = int(input())
a = list(rint())
s = set()
b = []
for i in range(n - 1, -1, -1):
	if not a[i] in s:
		b.append(a[i])
		s.add(a[i])
c = b[::-1]
print(len(c))
print(*c)


from sys import stdin, stdout
from math import gcd, ceil, sqrt
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
n = ii1()
arr = iia()
res = []
for i in arr[::-1]:
	if i not in res:
		res.append(i)
print(len(res))
print(*res[::-1])


def main():
	import sys
	from collections import OrderedDict
	l = int(sys.stdin.readline())
	nums = [int(x) for x in sys.stdin.readline().strip('\n').split(' ')]
	od = OrderedDict()
	for x in reversed(nums):
		od[x] = ''
	print(len(od.keys()))
	print(*reversed(od.keys()))
main()


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

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

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

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

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

def S():
	return input()

def main():
	n = I()
	l = LI()
	a = [True] * n
	for (i, x) in enumerate(l):
		for y in l[i + 1:]:
			if x == y:
				a[i] = False
	b = []
	for (i, x) in enumerate(l):
		if a[i]:
			b.append(x)
	print(len(b))
	print(' '.join([str(x) for x in b]))
main()


import typing
from typing import List, Tuple, Set

def preprocess(n: str, inputs: List[str]) -> Tuple[int, List[int]]:
	num: int = int(n)
	input_list: List[int] = list(map(lambda x: int(x), inputs.split()))
	return (num, input_list)

def keep_right_only(num: int, inp_list: List[int]):
	if num != len(inp_list):
		raise ValueError()
	ref_set: Set[int] = set()
	num_collector: List[int] = []
	for i in range(len(inp_list) - 1, -1, -1):
		if inp_list[i] not in ref_set:
			ref_set.add(inp_list[i])
			num_collector.insert(0, inp_list[i])
	return num_collector
n = input()
inputs = input()
(num, inp_list) = preprocess(n, inputs)
res = keep_right_only(num, inp_list)
print(len(res))
for (ind, elem) in enumerate(res):
	if ind == len(res) - 1:
		print(elem)
		break
	print(elem, end=' ')


n = int(input())
a = list(map(int, input().split()))
que = []
for i in a:
	if i in que:
		que.pop(que.index(i))
		que.append(i)
	else:
		que.append(i)
print(len(que))
for i in range(len(que)):
	que[i] = str(que[i])
print(' '.join(que))


n = int(input())
a = input().split()
res = []
seen = set()
for i in range(n - 1, -1, -1):
	if a[i] not in seen:
		res.append(a[i])
		seen.add(a[i])
reverse = []
for i in range(len(res) - 1, -1, -1):
	reverse.append(res[i])
print(len(res))
print(' '.join(reverse))


n = int(input())
ls = []
mem = []
dic = []
for j in range(1001):
	mem.append(0)
a = input().split(' ')
ls = a
for i in range(n):
	ls[i] = int(ls[i])
	mem[ls[i]] += 1
pr = ''
c = 0
for i in range(n):
	if mem[ls[i]] <= 1:
		c += 1
		pr += str(ls[i]) + ' '
	else:
		mem[ls[i]] -= 1
print(c)
print(pr)


def go():
	n = input()
	a = [int(i) for i in input().split(' ')]
	a = reversed(a)
	output = []
	keep = set()
	for i in a:
		if i not in keep:
			keep.add(i)
			output.insert(0, i)
	print(len(output))
	print(str(output)[1:-1].replace(',', ''))
go()


n = int(input())
arr = list(map(int, input().split()))
countocc = dict()
for i in arr:
	try:
		countocc[i] += 1
	except:
		countocc[i] = 1
temparr = [-1] * len(arr)
for i in countocc.keys():
	temparr[max((loc for (loc, integer) in enumerate(arr) if integer == i))] = i
outarr = [i for i in temparr if i != -1]
print(len(outarr))
print(*outarr)


n = int(input())
s = [i for i in input().split()]
s.reverse()
d = []
e = set()
for i in range(n):
	if s[i] not in e:
		d.append(s[i])
		e.add(s[i])
d.reverse()
print(len(d))
print(*d)


n = int(input())
mass = [int(s) for s in input().split()]
mass1 = []
for j in range(1, n + 1):
	for i in range(len(mass1)):
		if mass1[i] == mass[n - j]:
			break
	else:
		mass1.append(mass[n - j])
n = len(mass1)
print(n)
for j in range(n - 1, -1, -1):
	print(mass1[j], sep=' ', end=' ')


n = int(input())
s = list(map(int, input().split()))
ans = []
prev_occ = set()
for ch in s:
	if ch in prev_occ:
		ans.remove(ch)
	ans.append(ch)
	prev_occ.add(ch)
print(len(ans))
print(*ans)


import sys
from collections import *
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
f = set()
r = []
for i in range(n - 1, -1, -1):
	if a[i] not in f:
		f.add(a[i])
		r.append(a[i])
print(len(r))
print(*r[::-1])


R = lambda : map(int, input().split())
input()
a = []
for i in R():
	while i in a:
		del a[a.index(i)]
	a.append(i)
print(len(a))
print(*a)


number = int(input())
l_ist1 = input().split()
s = set(l_ist1)
for i in range(number - 1):
	for j in range(i + 1, number):
		if l_ist1[i] == l_ist1[j]:
			l_ist1[i] = ''
for i in range(number):
	if '' in l_ist1:
		l_ist1.remove('')
for i in l_ist1:
	if i == '':
		l_ist1.remove(i)
print(len(l_ist1))
for i in l_ist1:
	if i == '':
		continue
	else:
		print(i, end=' ')


n = int(input())
a = list(map(int, input().strip().split()))
new_arr = []
for i in range(n - 1, -1, -1):
	if a[i] not in new_arr:
		new_arr.append(a[i])
print(len(new_arr))
print(*new_arr[::-1])


n = int(input())
a = [int(i) for i in input().split()]
b = set()
print(len(set(a)))
c = []
for i in range(len(a) - 1, -1, -1):
	if not a[i] in b:
		b.add(a[i])
		c.append(a[i])
print(*c[::-1])


n = int(input())
a = list(map(str, input().split(' ')))
a.reverse()
b1 = []
b2 = set()
b1.append(a[0])
b2.add(a[0])
for i in range(1, n):
	if a[i] not in b2:
		b1.append(a[i])
		b2.add(a[i])
b1.reverse()
s = ''
for i in b1:
	s = s + i + ' '
print(len(b1))
print(s)


n = int(input())
arr = list(map(int, input().split()))
dict = {}
for i in range(n):
	dict[arr[i]] = i
ans = [i for (i, j) in sorted(dict.items(), key=lambda k: k[1])]
print(len(ans))
print(' '.join(map(str, ans)))


sp = []
n = input()
for i in range(0, 1):
	nmbrs = input()
	nmbrs = nmbrs.split(' ')
for s in nmbrs:
	if s in sp:
		sp.remove(s)
		sp.append(s)
	else:
		sp.append(s)
print(len(sp))
out = ''
for s in sp:
	out = out + s + ' '
print(out)


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

def dedupe(items):
	seen = set()
	for item in items:
		if item not in seen:
			yield item
			seen.add(item)
a = list(dedupe(reversed(line)))
print(len(a))
print(' '.join((str(i) for i in reversed(a))))


n = int(input())
l = list(map(int, input().strip().split()))
m = list(set(l))
x = []
for i in l[::-1]:
	for j in m:
		if i == j and j not in x:
			x.append(j)
print(len(x))
print(*x[::-1])


n = int(input(''))
arr0 = [int(a) for a in input('').split()]
arr1 = list(reversed(sorted(set(list(reversed(arr0))), key=list(reversed(arr0)).index)))
print(len(arr1))
for i in arr1:
	print(i, end=' ')
print('')


n = int(input())
li = list(map(int, input().split()))
l = [0]
se = set(li)
if len(se) == 1:
	print(1)
	print(li[0])
	exit()
else:
	for i in range(n - 1, 0, -1):
		if li[i] != li[i - 1]:
			co = 0
			for j in l:
				if j == li[i]:
					co += 1
			if co == 0:
				l.append(li[i])
	ci = 0
	for i in l:
		if li[0] == i:
			ci += 1
	if ci == 0:
		l.append(li[0])
	l2 = []
	for i in range(len(l) - 1, 0, -1):
		l2.append(l[i])
	print(len(l2))
	print(*l2, sep=' ')


n = int(input())
a = tuple(input().split())
s = set()
ans = list()
for i in a[::-1]:
	if i not in s:
		ans.append(i)
		s.add(i)
print(len(ans))
print(*ans[::-1])


def main():
	n = int(input())
	a = [int(_) for _ in input().split()]
	mark = [False] * (max(a) + 1)
	b = []
	for x in a[::-1]:
		if not mark[x]:
			b.append(x)
			mark[x] = True
	print(len(b))
	print(' '.join(map(str, b[::-1])))
main()


useless = input()
lis = input().split(' ')
lis2 = []
for i in range(len(lis)):
	lis[i] = int(lis[i])
for i in range(len(lis)):
	if lis[i] not in lis2:
		lis2.append(lis[i])
	else:
		lis2.remove(lis[i])
		lis2.append(lis[i])
print(len(lis2))
print(*lis2)


n = int(input())
l = list(map(int, input().split(' ')))
s = set()
l1 = list()
l.reverse()
for i in l:
	if not i in s:
		l1.append(i)
		s.add(i)
l1.reverse()
print(len(l1))
for i in l1:
	print(i, end=' ')


n = input()
new = []
arr = [int(x) for x in input().split()]
for i in reversed(arr):
	if not i in new:
		new.append(i)
print(len(new))
print(*new[::-1])


n = int(input())
arr = list(map(int, input().split()))
arr2 = []
arr3 = []
visited = set()
for i in reversed(range(len(arr))):
	if arr[i] not in visited:
		arr2.append(arr[i])
		visited.add(arr[i])
s = ''
s += str(arr2[len(arr2) - 1])
for i in reversed(range(len(arr2) - 1)):
	s += ' ' + str(arr2[i])
print(len(arr2))
print(s)


n = int(input())
arr = list(map(int, input().split()))
d = {}
for i in range(n):
	d[arr[i]] = i
ans = []
for i in d.keys():
	ans.append([d[i], i])
ans.sort()
print(len(ans))
for i in range(len(ans)):
	print(ans[i][1], end=' ')
print('')


n = int(input())
l = list(map(int, input().split()))
d = {}
z = []
for i in range(n):
	d[l[i]] = i
for i in d:
	z.append([d[i], i])
z.sort()
ans = []
for i in z:
	ans.append(i[1])
print(len(ans))
print(*ans)


n = int(input())
a = list(map(int, input().split()))
m = set()
b = []
for i in range(n - 1, -1, -1):
	if a[i] not in m:
		b = [str(a[i])] + b
	m.add(a[i])
print(len(b))
print(' '.join(b))