from collections import OrderedDict
n, m = map(int, input().split())
my_list = list(map(int, input().split()))

element_count = {}
for item in my_list:
    if item in element_count:
        element_count[item] += 1
    else:
        element_count[item] = 1

for item, count in element_count.items():
    if count == 1:
        my_list.remove(item)
print(my_list)

duplicates = list(OrderedDict.fromkeys(my_list))
print(len(duplicates))
str_out = ''
for i in range(len(duplicates)):
    str_out += str(duplicates[i]) + ' '
print(str_out)