#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <set>
#define long long long
#define LF '\n'
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;


signed main()
{
  cin.tie(nullptr), ios::sync_with_stdio(false);
  multiset<int> U;
  int Q;

  cin >> Q;
  while(Q--) {
    int com, x, y;
    cin >> com;

    switch(com) {
    case 0:
      cin >> x;
      U.insert(x);
      cout << U.size() << LF;
      break;

    case 1:
      cin >> x;
      cout << U.count(x) << endl;
      break;

    case 2:
      cin >> x;
      U.erase(x);
      break;

    default:
      cin >> x >> y;
      for (auto it = U.lower_bound(x), end=U.upper_bound(y); it != end; ++it) {
        cout << *it << LF;
      }
    }
  }

  return 0;
}


