样例输入:
10
20 40 32 67 40 20 89 300 400 15
样例输出:
8
15 20 32 40 67 89 300 400
import java.util.Scanner;
import java.util.TreeSet;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
TreeSet<Integer> ts = new TreeSet<Integer>();
for(int i = 0; i < n; i ++) {
ts.add(scan.nextInt());
}
int ans = 0;
System.out.println(ts.size());
for(Integer i : ts) {
ans++;
System.out.print(i);
if(ans != ts.size())
System.out.print(" ");
}
}
}