#include <iostream>
#include <set>
using namespace std;
int main() {
// your code goes here
multiset<int> s{1, 1, 1, 3, 4, 5};
int n = 5;
int idx = 0;
auto it = s.begin();
while(idx < n - 1){
idx++;
cout << *it << " ";
it++;
}
it--;
cout << *it << "\n";
s.insert(2);
it--;
cout << *it << "\n";
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c2V0Pgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CgkvLyB5b3VyIGNvZGUgZ29lcyBoZXJlCgltdWx0aXNldDxpbnQ+IHN7MSwgMSwgMSwgMywgNCwgNX07CgkKCWludCBuID0gNTsKCWludCBpZHggPSAwOwoJYXV0byBpdCA9IHMuYmVnaW4oKTsKCXdoaWxlKGlkeCA8IG4gLSAxKXsKCQlpZHgrKzsKCQljb3V0IDw8ICppdCA8PCAiICI7CgkJaXQrKzsKCX0KCWl0LS07Cgljb3V0IDw8ICppdCA8PCAiXG4iOwoJCglzLmluc2VydCgyKTsKCWl0LS07Cgljb3V0IDw8ICppdCA8PCAiXG4iOwoJcmV0dXJuIDA7Cn0=