java
import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int N = scan.nextInt();
int[] arr = new int[N];
for (int i = 0; i < N; i++) {
int n = scan.nextInt();
arr[i] = n;
}
int count = getSortArr(arr);
int i = 0;
while (i < count) {
System.out.println(arr[i]);
i++;
}
}
public static int getSortArr(int[]src) {
//插入排序
for (int i = 1; i < src.length; i++) {
int temp = src[i];
int j = 0;
for (j = i - 1; j >= 0 && temp < src[j]; j--) {
src[j + 1] = src[j];
}
src[j + 1] = temp;
}
//双指针去重
int slow = 0, fast = 1;
while (slow < fast && fast < src.length) {
if (src[slow] == src[fast]) {
fast++;
continue;
}
slow++;
src[slow] = src[fast];
fast++;
}
return slow + 1;//有效长度
}
}