#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
#define INF           1e9
#define INFL          static_cast<lint>(INF)
#define REP(i,n)      for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)     for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)     for(lint i=n-1;i>=0;--i)
#define REPR1(i,n)    for(lint i=n;i>0;--i)
#define REPI(i,ini,n) for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPC(i,obj)   for(auto i:obj)
#define R_UP(a,b)     (((a)+(b)-1)/(b))
#define ALL(obj)      (obj).begin(),(obj).end()
int main()
{
	int q = in();
	multiset<int>s;
	REP(i, q)
	{
		int n = in();
		int x, l, r;
		switch (n)
		{
		case 0:
			x = in();
			s.insert(x);
			cout << s.size() << endl;
			break;
		case 1:
			x = in();
			cout << distance(s.lower_bound(x), s.upper_bound(x)) << endl;
			break;
		case 2:
			x = in();
			s.erase(s.lower_bound(x), s.upper_bound(x));
			break;
		case 3:
			l = in();
			r = in();
			for (auto start = s.lower_bound(l), last = s.upper_bound(r); start != last; start++)cout << *start << endl;
			break;
		}
	}
}
