#CCBCHBAHAI0000045. Remove Duplicates (Remove Duplicates)

Remove Duplicates (Remove Duplicates)

Remove Duplicates (Remove Duplicates)

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem

Given an integer array a0,a1,…,an−1a_0,a_1,\ldots,a_{n-1}.

For each value appearing in the array, keep only its rightmost occurrence. The relative order among the retained elements must remain the same as in the original array.

An index ii is retained if and only if no equal value appears to its right:

∄j  (i<j<n ∧ aj=ai).\nexists j\;\bigl(i<j<n\ \land\ a_j=a_i\bigr).

If the retained indices are

i0<i1<⋯<im−1,i_0<i_1<\cdots<i_{m-1},

print mm and

ai0,ai1,…,aim−1.a_{i_0},a_{i_1},\ldots,a_{i_{m-1}}.

Input

The first line contains integer nn. The second line contains nn integers a0,a1,…,an−1a_0,a_1,\ldots,a_{n-1}.

Output

Print the number of remaining elements mm on the first line. Print the resulting mm elements on the second line.

Subtask

Subtask 1 (100 points): 1≤n≤501\le n\le50; 1≤ai≤10001\le a_i\le1000.

Example

Input

6
1 5 5 1 6 1

Output

3
5 6 1

Explanation

For value 11, only the occurrence at index 5 remains; for value 55, only the occurrence at index 2 remains; value 66 remains. The retained indices are 2,4,52,4,5, so the result is 5 6 1.