#include<bits/stdc++.h>
#define lli long long int
#define FILE_IN freopen("input.txt", "r", stdin);
#define FILE_OUT freopen("output.txt", "w", stdout);
#define PI acos(-1)
using namespace std;
void fastio()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);
  cout. tie(0);

}
int main() {
 fastio();
  int f,t,x,y;
    multiset<int>s;
 multiset<int>::iterator it1,it2;
    cin>>t;
    while(t--) {
        cin>>f>>x;
        if(f==0) {
            s.insert(x);
            cout<<s.size()<<endl;
        }
        else if(f==1)
            cout<<s.count(x)<<endl;

       else if(f==2)
          s.erase(x);

       else{
          cin>>y;

         it1=s.lower_bound(x);
         it2=s.upper_bound(y);
         for(;it1 != it2;it1++)
          cout<<*it1<<endl;
       }

}
    return 0;
}


