根据set的特性进行去重,然后使用stream流式转换进行排序和输出

import java.util.Set;
import java.util.TreeSet;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            Set set = new TreeSet();
            for(int i=0;i<n;i++){
                set.add(in.nextInt());
            }
            set.stream().sorted().forEach(System.out::println);
        }
    }
}