以下是解法
#include <stdio.h>
int main() {
int count[4] = {0};
long long num = 0;
int tmp = 0;
scanf("%lld", &num);
for (int i = 0; i < num; i++) {
scanf("%d", &tmp);
if (tmp == 1)
count[1]++;
else if (tmp - 2)
count[3]++;
else
count[2]++;
}
for (int i = 1; i <= 3; i++)
for (int j = 0; j < count[i]; j++) {
printf("%d ", i);
}
return 0;
}