集合运算:

import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Set<Integer> s = new HashSet<>();
        while (sc.hasNext()){
            int n = sc.nextInt();
            if(s.contains(n)) continue;
            s.add(n);
            System.out.printf("%d ", n);
        }
    }
}