#include <iostream>

#include <algorithm>
#include <vector>

template <typename T, typename Comp>
void insert_sorted(std::vector<T>& vec, T const& e, Comp const& comp) {
	auto const it = std::lower_bound(vec.begin(), vec.end(), e, comp);
	
	if (it != vec.end() and not comp(e, *it)) { return; }
	
	vec.insert(it, e);
}

template <typename T>
void insert_sorted(std::vector<T>& vec, T const& e) {
	insert_sorted(vec, e, std::less<T>{});
}

int main() {
	int const array[] = { 4, 3, 6, 2, 3, 6, 8, 4 };
	
	std::vector<int> vec;
	for (int a: array) {
		insert_sorted(vec, a);
	}
	
	std::cout << vec.size() << ":";
	for (int a: vec) { std::cout << " " << a; }
	std::cout << "\n";
	
	return 0;
}