#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int q; cin >> q;
    multiset<int> a;
    decltype(a)::iterator itr1;
    decltype(a)::iterator itr2;
    rep(i ,q){
        int m , x , y;
        cin >> m >> x;
        switch (m)
        {
        case 0: 
            a.insert(x);
            cout << a.size() << endl; 
            break;
        case 1:
            cout << a.count(x) << endl;
            break;
        case 2:
            a.erase(x);
            break;
        case 3:
            cin >> y;
            if(a.empty()) break;
            else { 
                set<int>::iterator itr1,itr2;
                itr1 = a.lower_bound(x);
                itr2 = a.upper_bound(y);
                set<int>::iterator it = itr1;
                while(it != itr2){
                    cout << *(it++) << endl;
                }
            }
            break;
        }
    }
}
