#include <bits/stdc++.h>
using namespace std;

int main(void){
    multiset<int> mlS;
    multiset<int>::iterator begin, end;
    int q;
    cin >> q;

    for(int i=0; i<q; i++){
        int cmd;
        cin >> cmd;
        if(cmd==0){
            int x;
            cin >> x;
            mlS.insert(x);
            cout << mlS.size() << "\n";
        }
        else if(cmd==1){
            int x;
            cin >> x;
            cout << mlS.count(x) << "\n";
        }
        else if(cmd==2){
            int x;
            cin >> x;
            mlS.erase(x);
        }
        else if(cmd==3){
            int L,R;
            cin >> L >> R;
            begin = mlS.lower_bound(L);
            end = mlS.upper_bound(R);
            for(; begin!=end; begin++){
                cout << *begin << "\n";
            }
        }
    }
    return 0;
}
