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: introductory

Starter code:

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

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


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

# ANSHUL GAUTAM
# IIIT-D
 



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)





















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 = 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())
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())
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 = list(map(int, input().split()))

b = []

for i in a[::-1]:
    if i not in b:
        b.append(i)
print(len(b))
print(' '.join(map(str, b[::-1])))

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


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)

# your code goes here
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())
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= ' ')

def __starting_point():
    n = int(input())
    l = list(map(int, input().split()))
    k = []

    for i in range(n-1,-1,-1):
        if l[i] not in k:
            k.append(l[i])

    k = list(reversed(k))
    print(len(k))
    for i in k:
        print(i,end=' ')
__starting_point()

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

d = set()

n = int(input())
a = [int(x) for x in input().split()]
b = []
for i in range(n - 1, -1, -1):
    if a[i] in d:
        continue
    b.append(a[i])
    d.add(a[i])
b.reverse()

print(len(b))
for x in b:
    print(x, end=' ')


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

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

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=[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())
a = list(map(int, input().split()))
new = []
was = set()
for i in range(n - 1, -1 , -1):
    if a[i] not in was:
        new.append(a[i])
        was.add(a[i])
print(len(new))
for i in range(len(new) - 1, -1, -1):
    print(new[i], end=' ')

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