#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;

int main(void)
{
	int q, com, x;
	multiset<int> S;
    cin >> q;
    rep(i, q)
    {
        cin >> com >> x;
        if (com == 0)
        {
            S.insert(x);
            cout << S.size() << endl;
        }
        else if (com == 1)
        {
            cout << S.count(x) << endl;
        }
        else if (com == 2)
        {
            S.erase(x);
        }
        else
        {
            int y;
            cin >> y;
            set<int>::iterator st, en, itr;
            st = S.lower_bound(x);
            en = S.upper_bound(y);
            for(itr = st; itr != en; ++itr) {
                cout << *itr << endl;
            }
        }
    }
}
