#include <cstdio>
#include <cassert>
#include <vector>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T> using Tree = tree<T, null_type, greater<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
  vector<int> a = {1, 2, 3, 1, 1};
	Tree<int> s(a.begin(), a.end());

	// s.insert(1);
	// s.insert(2);
	// s.insert(3);
	// s.insert(1);
	// s.insert(1);
	for (int a : s)
		printf("%d ", a);
	puts(" ");
	printf("ord(3) = %d\n", (int)s.order_of_key(3));
	printf("ord(2) = %d\n", (int)s.order_of_key(2));
}