// nlather (Nishant Raj Lather)
// Chrollo_Lucifer

/* ------------------------------ TEMPLATE BEGIN ------------------------------ */

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

/* ----------------- ORDERED SET (POLICY BASED DS) ----------------- */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree
    <T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;

/* -------------- BETTER RANDOM (RAND() IS DANGEROUS) -------------- */
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rnd(x, y) uniform_int_distribution<ll>(x, y)(rng)

/* ----------------- CUSTOM HASH FUNCTION FOR UMAP ----------------- */
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(tuple<uint64_t,uint64_t,uint64_t> x) const {
        uint64_t a, b, c;
        tie(a,b,c) = x;
        static const uint64_t FIXED_RANDOM =
            chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(a+b*uint64_t(1e6)+c*uint64_t(1e12) + FIXED_RANDOM);
    }
};

/* ----------------------- DEBUGGING UTILITY ----------------------- */
#define cerr cout
void _print() {cerr << "]\n";}
template <typename T, typename... V> void _print(T t, V... v) {
    cerr << t; if(sizeof...(v)) cerr << ", "; _print(v...);
}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define rep(i, x, n) for (ll i = (ll)(x); i < (ll)(n); i++)
#define rrep(i, x, n) for (ll i = (ll)(x); i >= (ll)(n); i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define bs binary_search
#define minSelf(a, b) a = min(a, b)
#define maxSelf(a, b) a = max(a, b)
#define mem(arr, x) memset(arr, x, sizeof(arr))
using ll = long long int;
using ld = long double;
template <typename T, typename V> using P = pair<T, V>;
template <typename T> using V = vector<T>;
constexpr ll MOD = 1e9+7;
constexpr ll INF = 0x3f3f3f3f; // ~1e9 (1061109567)
constexpr ld PI = 3.1415926535897932384626;
constexpr ld EPS = 1e-9;
#define endl '\n' // REMOVE FOR INTERACTIVE TASKS
constexpr ll MAX = 1e5+5;

/* ------------------------------- TEMPLATE END ------------------------------- */

int main() {
    ll n, a, r, m;
    cin >> n >> a >> r >> m;
    m = min(m, a+r);
    V<ll> v(n);
    ll mx = 0;
    rep(i, 0, n) cin >> v[i], mx = max(mx,v[i]);
    auto solve = [&](ll h) {
        ll mor = 0, les = 0, ans = 0;
        for(ll &i: v) mor += max(0ll,i-h), les += max(0ll,h-i);
        if(mor > les) ans = (mor-les)*r;
        else ans = (les-mor)*a;
        return ans+min(mor, les)*m;
    };
    ll lo = 0, hi = mx, ans = INF;
    while(lo <= hi) {
        ll mid = (lo+hi)/2;
        ll ans_1 = solve(mid), ans_2 = solve(mid+1);
        if(ans_1 < ans_2) ans = ans_1, hi = mid-1;
        else ans = ans_2, lo = mid+1;
    }
    cout << ans << endl;
}


// nlather (Nishant Raj Lather)
// Chrollo_Lucifer

/* ------------------------------ TEMPLATE BEGIN ------------------------------ */

#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,mmx,avx,avx2,fma,tune=native")
#pragma GCC optimize("unroll-loops")

/* ----------------- ORDERED SET (POLICY BASED DS) ----------------- */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree
    <T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;

/* -------------- BETTER RANDOM (RAND() IS DANGEROUS) -------------- */
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rnd(x, y) uniform_int_distribution<ll>(x, y)(rng)

/* ----------------- CUSTOM HASH FUNCTION FOR UMAP ----------------- */
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(tuple<uint64_t,uint64_t,uint64_t> x) const {
        uint64_t a, b, c;
        tie(a,b,c) = x;
        static const uint64_t FIXED_RANDOM =
            chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(a+b*uint64_t(1e6)+c*uint64_t(1e12) + FIXED_RANDOM);
    }
};

/* ----------------------- DEBUGGING UTILITY ----------------------- */
#define cerr cout
void _print() {cerr << "]\n";}
template <typename T, typename... V> void _print(T t, V... v) {
    cerr << t; if(sizeof...(v)) cerr << ", "; _print(v...);
}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define rep(i, x, n) for (ll i = (ll)(x); i < (ll)(n); i++)
#define rrep(i, x, n) for (ll i = (ll)(x); i >= (ll)(n); i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define bs binary_search
#define minSelf(a, b) a = min(a, b)
#define maxSelf(a, b) a = max(a, b)
#define mem(arr, x) memset(arr, x, sizeof(arr))
using ll = long long int;
using ld = long double;
template <typename T, typename V> using P = pair<T, V>;
template <typename T> using V = vector<T>;
constexpr ll MOD = 1e9+7;
constexpr ll INF = 0x3f3f3f3f; // ~1e9 (1061109567)
constexpr ld PI = 3.1415926535897932384626;
constexpr ld EPS = 1e-9;
#define endl '\n' // REMOVE FOR INTERACTIVE TASKS
constexpr ll MAX = 1e5+5;

/* ------------------------------- TEMPLATE END ------------------------------- */

int main() {
    ll n, a, r, m;
    scanf("%lld%lld%lld%lld", &n, &a, &r, &m);
    m = min(m, a+r);
    ll v[n], mx = 0;
    rep(i, 0, n) cin >> v[i], mx = max(mx,v[i]);
    auto solve = [&](ll h) {
        ll mor = 0, les = 0, ans = 0;
        rep(i, 0, n) mor += max(0ll,v[i]-h), les += max(0ll,h-v[i]);
        if(mor > les) ans = (mor-les)*r;
        else ans = (les-mor)*a;
        return ans+min(mor, les)*m;
    };
    ll lo = 0, hi = mx, ans = INF;
    while(lo <= hi) {
        ll mid = (lo+hi)/2;
        ll ans_1 = solve(mid), ans_2 = solve(mid+1);
        if(ans_1 < ans_2) ans = ans_1, hi = mid-1;
        else ans = ans_2, lo = mid+1;
    }
    printf("%lld", ans);
}


// nlather (Nishant Raj Lather)
// Chrollo_Lucifer

/* ------------------------------ TEMPLATE BEGIN ------------------------------ */

#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")

/* ----------------- ORDERED SET (POLICY BASED DS) ----------------- */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree
    <T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;

/* -------------- BETTER RANDOM (RAND() IS DANGEROUS) -------------- */
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rnd(x, y) uniform_int_distribution<ll>(x, y)(rng)

/* ----------------- CUSTOM HASH FUNCTION FOR UMAP ----------------- */
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(tuple<uint64_t,uint64_t,uint64_t> x) const {
        uint64_t a, b, c;
        tie(a,b,c) = x;
        static const uint64_t FIXED_RANDOM =
            chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(a+b*uint64_t(1e6)+c*uint64_t(1e12) + FIXED_RANDOM);
    }
};

/* ----------------------- DEBUGGING UTILITY ----------------------- */
#define cerr cout
void _print() {cerr << "]\n";}
template <typename T, typename... V> void _print(T t, V... v) {
    cerr << t; if(sizeof...(v)) cerr << ", "; _print(v...);
}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define rep(i, x, n) for (ll i = (ll)(x); i < (ll)(n); i++)
#define rrep(i, x, n) for (ll i = (ll)(x); i >= (ll)(n); i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define bs binary_search
#define minSelf(a, b) a = min(a, b)
#define maxSelf(a, b) a = max(a, b)
#define mem(arr, x) memset(arr, x, sizeof(arr))
using ll = long long int;
using ld = long double;
template <typename T, typename V> using P = pair<T, V>;
template <typename T> using V = vector<T>;
constexpr ll MOD = 1e9+7;
constexpr ll INF = 0x3f3f3f3f; // ~1e9 (1061109567)
constexpr ld PI = 3.1415926535897932384626;
constexpr ld EPS = 1e-9;
#define endl '\n' // REMOVE FOR INTERACTIVE TASKS
constexpr ll MAX = 1e5+5;

/* ------------------------------- TEMPLATE END ------------------------------- */

int main() {
    ll n, a, r, m;
    scanf("%lld%lld%lld%lld", &n, &a, &r, &m);
    m = min(m, a+r);
    ll v[n], mx = 0;
    rep(i, 0, n) cin >> v[i], mx = max(mx,v[i]);
    auto solve = [&](ll h) {
        ll mor = 0, les = 0, ans = 0;
        rep(i, 0, n) mor += max(0ll,v[i]-h), les += max(0ll,h-v[i]);
        if(mor > les) ans = (mor-les)*r;
        else ans = (les-mor)*a;
        return ans+min(mor, les)*m;
    };
    ll lo = 0, hi = mx, ans = INF;
    while(lo <= hi) {
        ll mid = (lo+hi)/2;
        ll ans_1 = solve(mid), ans_2 = solve(mid+1);
        if(ans_1 < ans_2) ans = ans_1, hi = mid-1;
        else ans = ans_2, lo = mid+1;
    }
    printf("%lld", ans);
}


// nlather (Nishant Raj Lather)
// Chrollo_Lucifer

/* ------------------------------ TEMPLATE BEGIN ------------------------------ */

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

/* ----------------- ORDERED SET (POLICY BASED DS) ----------------- */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree
    <T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;

/* -------------- BETTER RANDOM (RAND() IS DANGEROUS) -------------- */
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rnd(x, y) uniform_int_distribution<ll>(x, y)(rng)

/* ----------------- CUSTOM HASH FUNCTION FOR UMAP ----------------- */
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(tuple<uint64_t,uint64_t,uint64_t> x) const {
        uint64_t a, b, c;
        tie(a,b,c) = x;
        static const uint64_t FIXED_RANDOM =
            chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(a+b*uint64_t(1e6)+c*uint64_t(1e12) + FIXED_RANDOM);
    }
};

/* ----------------------- DEBUGGING UTILITY ----------------------- */
#define cerr cout
void _print() {cerr << "]\n";}
template <typename T, typename... V> void _print(T t, V... v) {
    cerr << t; if(sizeof...(v)) cerr << ", "; _print(v...);
}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define rep(i, x, n) for (ll i = (ll)(x); i < (ll)(n); i++)
#define rrep(i, x, n) for (ll i = (ll)(x); i >= (ll)(n); i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define bs binary_search
#define minSelf(a, b) a = min(a, b)
#define maxSelf(a, b) a = max(a, b)
#define mem(arr, x) memset(arr, x, sizeof(arr))
using ll = long long int;
using ld = long double;
template <typename T, typename V> using P = pair<T, V>;
template <typename T> using V = vector<T>;
constexpr ll MOD = 1e9+7;
constexpr ll INF = 0x3f3f3f3f; // ~1e9 (1061109567)
constexpr ld PI = 3.1415926535897932384626;
constexpr ld EPS = 1e-9;
#define endl '\n' // REMOVE FOR INTERACTIVE TASKS
constexpr ll MAX = 1e5+5;

/* ------------------------------- TEMPLATE END ------------------------------- */

int main() {
    ll n, a, r, m;
    scanf("%lld%lld%lld%lld", &n, &a, &r, &m);
    m = min(m, a+r);
    ll v[n], mx = 0;
    rep(i, 0, n) cin >> v[i], mx = max(mx,v[i]);
    auto solve = [&](ll h) {
        ll mor = 0, les = 0, ans = 0;
        #pragma omp parallel for schedule(dynamic) reduction(+:mor) reduction(+:les)
        rep(i, 0, n) mor += max(0ll,v[i]-h), les += max(0ll,h-v[i]);
        if(mor > les) ans = (mor-les)*r;
        else ans = (les-mor)*a;
        return ans+min(mor, les)*m;
    };
    ll lo = 0, hi = mx, ans = INF;
    while(lo <= hi) {
        ll mid = (lo+hi)/2;
        ll ans_1 = solve(mid), ans_2 = solve(mid+1);
        if(ans_1 < ans_2) ans = ans_1, hi = mid-1;
        else ans = ans_2, lo = mid+1;
    }
    printf("%lld", ans);
}


from math import floor
t = int(input())
for x in range(t):
    n = int(input())
    if n == 1 or n == 2:
        print(1)
    elif n == 3:
        print(2)
    elif n%2 == 1:
        print(floor(n/2) + 1)
    elif n%2==0:
        print(n/2)


from math import floor
t = int(input())
for x in range(t):
    n = int(input())
    if n == 1 or n == 2:
        print(1)
    elif n == 3:
        print(2)
    else:
        print(floor(n/2))


for ti in range(int(input())):
    n=int(input())
    if n>2 and n%2==1:
        print(n//2+1)
    elif n>2 and n%2==0:
        print(n/2)
    else:
        print(1)


for ti in range(int(input())):
    n=int(input())
    if n%2==1:
        print(n//2+1)
    else:
        print(n//2)


for ti in range(int(input())):
    n=int(input())
    if n>2 and n%2==1:
        print(n//2+1)
    elif n>2 and n%2==0:
        print(n//2)
    else:
        print(1)


for ti in range(int(input()):
    n=int(input())
    if n>2:
        print(n//2)
    else:
        print(1)


for ti in range(int(input())):
    n=int(input())
    if n>2:
        print(n//2)
    else:
        print(1)


for ti in range(int(input()):
    n=int(input())
    if n>2 and n%2==1:
        print(n//2+1)
    elif n>2 and n%2==0:
        print(n/2)
    else:
        print(1)


for o in range(int(input())):
	n = int(input())
	if n%2 != 0:
		print(n//2 +1)
	else:
		print(n//2)


for o in range(int(input())):
    n = int(input())
    if i^1 == 0:
        print(n//2 +1)
    else:
        print(n//2)


for _ in range(int(input())):
    n=int(input())
    if n%2==1:
        print(int(n/2)+1)
    else:
        print(int(n/2))


for _ in range(int(input())):
    n=int(input())
    k=n
    count=1
    for i in range(1,1000):
        for j in range(i+1,n):
            if(i+j)==k:
                count+=1
            elif(i+j)<k:
                j+=1
            else:
                i+=1
    print(count)


for _ in range(int(input())):
    n=int(input())
    k=n
    count=1
    if n==1 or n==2:
        print("1")
    for i in range(1,n):
        if(n-i+1)==k:
            count+=1
    print(count)


for _ in range(int(input())):
    n=int(input())
    k=n
    count=1
    for i in range(1,n):
        for j in range(i+1,n):
            if(i+j)==k:
                count+=1
            elif(i+j)<k:
                j+=1
            else:
                i+=1
    print(count)


for _ in range(int(input())):
    n=int(input())
    k=n
    count=1
    i=0
    j=n-1
    while i<j:
        if(i+j)==k:
            count+=1
            print(count)
            break
        elif(i+j)<k:
            i+=1
        elif(i+j)>k:
            j-=1
    else:
        print(count)


for _ in range(int(input())):
    n=int(input())
    if n==1:
        print("1")
    else:
        print(n/2)


for _ in range(int(input())):
    n = int(input())
    if n == 1 :
        print(1)
    elif n == 3:
        print(2)
    else:
        print(n // 2)


for _ in range(int(input())):
    n = int(input())
    if n == 1 :
        print(1)
    else:
        print(n // 2)


for _ in range(int(input())):
    n = int(input())
    if n % 2 == 0:
        print(n // 2)
    else:
        print(n // 2 + 1)


import math
for _ in range(int(input())):
    print(math.ceil(int(input()) / 2))


import math
print(math.ceil(int(input()) / 2))


import math
for _ in range(int(input())):
    n = int(input())
    tp = math.ceil(n/2)
    print(n-tp)


import math
for _ in range(int(input())):
    n = int(input())
    if n<=3:
        print(math.ceil(n/2))
    else:
        print(n//2)


import math
for _ in range(int(input())):
    n = int(input())
    if n<=3:
        print(math.ceil(n/2))
    else:
        print(math.floor(n/2))


import math
for _ in range(int(input())):
    n = int(input())
    print((n+1)//2)


tc=int(input())
for ctr in range(tc):
    n=int(input())
    if n%2==0:
        print(n/2)
    else:
        print((n/2)+1)


tc=int(input())
for ctr in range(tc):
    a=int(input())
    if a%2==0:
        print(n/2)
    else:
        print(n/2+1)


tc=int(input())
for ctr in range(tc):
    n=int(input())
    if n%2==0:
        print(n//2)
    else:
        print((n//2)+1)


n= int(input())
a =[]
for i in range (n):
	l=int(input())
	if l ==1 :
		a.append(1)
	elif l==3:
		a.append(2)
	elif l%2==0:
		a.append(l//2)
	else:
		a.append(l//2)
for i in a:
	print (i)


n= int(input())
a =[]
for i in range (n):
	l=int(input())
	if l%2==0:
		a.append(l//2)
	else:
		a.append(l//2+1)
for i in a:
	print (i)


import math
n=int(input())
for i in range(n):
    m=int(input())

    if m%2==0:
        print(m//2)
    else:
        print((m+1)//2)


n=int(input())
for i in range(n):
    m=int(input())
    z=[]
    c=1
    for i in range(1,m+1):
        for j in range(i+1,m+1):
            if i not in z and j not in z:
                if i+j==m:
                    c+=1
                    z.append(i);z.append(j)
    print(c)


t = int(input())
l = []
for i in range(t):
    l.append(int(input()))
for i in range(t):
    if l[i] <= 3:
        if l[i] == 1 or l[i] == 2:
            print(1)
        else:
            print(2)
    else:
        print(n // 2)


t = int(input())
l = []
for i in range(t):
    l.append(int(input()))
for i in range(t):
    if l[i] <= 3:
        if l[i] == 1 or l[i] == 2:
            print(1)
        else:
            print(2)
    else:
        if l[i] % 2 == 0
            print(l[i] / 2)
        else:
            print((l[i] + 1) / 2)


t = int(input())
l = []
for i in range(t):
    l.append(int(input()))
for i in range(t):
    if l[i] <= 3:
        if l[i] == 1 or l[i] == 2:
            print(1)
        else:
            print(2)
    else:
        if l[i] % 2 == 0:
            print(l[i] / 2)
        else:
            print((l[i] + 1) / 2)


t = int(input())
l = []
for i in range(t):
    l.append(int(input()))
for i in range(t):
    if l[i] > 3:
        print(l[i] // 2)
    elif l[i] == 3:
        print(2)
    else:
        print(1)


t = int(input())
l = []
for i in range(t):
    l.append(int(input()))
for i in range(t):
    if l[i] <= 3:
        if l[i] == 1 or l[i] == 2:
            print(1)
        else:
            print(2)
    else:
        if l[i] % 2 == 0
            print('%d' % (l[i] / 2))
        else:
            print('%d' % ((l[i] + 1) / 2))


t = int(input())
l = []
for i in range(t):
    l.append(int(input()))
for i in range(t):
    if l[i] <= 3:
        if l[i] == 1 or l[i] == 2:
            print(1)
        else:
            print(2)
    else:
        if l[i] % 2 == 0:
            print('%d' % (l[i] / 2))
        else:
            print('%d' % ((l[i] + 1) / 2))


t = int(input())
l = []
for i in range(t):
    l.append(int(input()))
for i in range(t):
    if l[i] > 3:
        while True:
            l[i] /= 2
            if l[i] == 2 or l[i] == 3:
                print('%d' % l[i])
                break
    elif l[i] == 3:
        print(2)
    else:
        print(1)


t = int(input())
l = []
for i in range(t):
    l.append(int(input()))
for i in range(t):
    if l[i] <= 3:
        if l[i] == 1 or l[i] == 2:
            print(1)
        else:
            print(2)
    else:
        print(l[i] // 2)


t = int(input())
l = []
for i in range(t):
    l.append(int(input()))
for i in range(t):
    if l[i] <= 3:
        if l[i] == 1 or l[i] == 2:
            print(1)
        else:
            print(2)
    else:
        print(2)


t = int(input())
l = []
for i in range(t):
    l.append(int(input()))
for i in range(t):
    if l[i] <= 3:
        if l[i] == 1 or l[i] == 2:
            print(1)
        else:
            print(2)
    else:
        if l[i] % 2 == 0:
            l[i] /= 2
        else:
            l[i] = l[i] // 2 + 1
        while True:
            if l[i] == 2 or l[i] == 3:
                break
            l[i] //= 2
        print('%d' % l[i])


t = gets.to_i
t.times do
	n = gets.to_i
	p (n + 1) / 2
end


require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
t = gets.chomp.to_i
t.times do
  n = gets.chomp.to_i
  puts (n+1)/2
end


require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
t = gets.chomp.to_i
t.times do
  v,c,n,m = gets.chomp.split.map(&:to_i)
  v,c=c,v if v > c
  if v < m
    puts 'No'
  else
    v -= m
    if v + c < n
      puts 'No'
    else
      puts 'Yes'
    end
  end
end


n = gets.chomp.to_i
n.times do
    t = gets.chomp.to_i
    if t % 2 == 1 && t >= 3
        kai = t -1
        kazu = kai / 2
        puts kazu + 1
    elsif t % 2 == 1 && t < 3
        puts "1"
    elsif  t % 2 == 0 && t >= 2
        puts t / 2
    end
end


t=gets.chomp.to_i
for i in 1..t
	n=gets.chomp.to_i
	puts"#{(1+n)/2}"
end


T = gets.to_i
for i in 1..T
  x = gets.to_i
  puts (x + 1) / 2
end


def f(n)
  return 0 if n.zero?
  n.even? ? n / 2 : f(n - 1) + 1
end

gets.to_i.times do
  puts f(gets.to_i)
end


def f(n)
  return 1 if n == 1
  return 2 if n == 3

  n / 2
end

gets.to_i.times do
  puts f(gets.to_i)
end


def get_res(n)
  res = n / 2
  res += 1 if (n % 2 == 1)
  return res
end

def solve
  t = gets.chomp
  (0..t.to_i).each {puts get_res(gets.chomp.to_i)}
end

solve


def get_res(n)
  res = n / 2
  res += 1 if (n % 2 == 1)
  return res
end

def solve
  t = gets.chomp
  (1..t.to_i).each {puts get_res(gets.chomp.to_i)}
end

solve


import sys
input = sys.stdin.readline

def solve(n):
	if n <= 2:
		return 1
	if n == 3:
		return 2
	return n//2

if __name__ == "__main__":
	t = int(input())
	for _ in range(t):
		n = int(input())
		print(solve(n))
'''
1234
14 23

12345
15 24

12346
'''


import sys
input = sys.stdin.readline

def solve(n):
	if n <= 2:
		return 1
	if n == 3:
		return 2
	return (n+1)//2

if __name__ == "__main__":
	t = int(input())
	for _ in range(t):
		n = int(input())
		print(solve(n))
'''
1234
14 23

12345
15 24

123456
'''


from sys import stdin, stdout

def main():
	N = int(stdin.readline().rstrip())
	for _ in range(N):
		n = int(stdin.readline().rstrip())
		isEven = False
		if n % 2 == 0:
			isEven = True
		else:
			isEven = False
			n-=1
		ans = n / 2
		if not isEven:
			ans +=1
		stdout.write(str(ans)+'\n')
if __name__ == "__main__":
	main()


from sys import stdin
t = int(stdin.readline())
for _ in xrange(t):
    n = int(stdin.readline())
    print (n+1)/2


for _ in range(input()):
    n=input()
    print n/2+n%2


for _ in range(input()):
  n = input()
  if n%2==1: print n/2+1
  else : print n/2


n = int(raw_input())
ans = []
for i in range(n):
    a = int(raw_input())
    if a%2==0:
        ans.append(a/2)
    else:
        ans.append((a/2)+1)
for v in range(len(ans)):
    print ans[v]


caseNum = input()
inputs = []
for x in range(0,caseNum):
    inputs.append(input())
print inputs

for x in range(0,len(inputs)):
    num = inputs[x]

    if num % 2 == 0:
        print (num/2)

    else:
        print (num-1)/2


caseNum = input()
inputs = []
for x in range(0,caseNum):
    inputs.append(input())

for x in range(0,len(inputs)):
    num = inputs[x]

    if num % 2 == 0:
        print (num/2)

    else:
        print (num+1)/2


caseNum = input()
inputs = []
for x in range(0,caseNum):
    inputs.append(input())

for x in range(0,len(inputs)):
    num = inputs[x]

    if num % 2 == 0:
        print (num/2)

    else:
        print (num-1)/2


caseNum = input()
inputs = []
for x in range(0,caseNum):
    inputs.append(input())

for x in range(0,len(inputs)):
    num = inputs[x]

    if num % 2 == 0:
        print (num/2)

    else:
        print (num-1)/2
#test


t =int(input())
while(t>0):
    n =int(input())
    if n==1:
        print(1)
    elif n&1==1:
        n-=1
        print(n//2+1)
    else:
        print(n//2)
    t-=1


read = lambda : map(int, raw_input().split())

t, = read()

for _ in xrange(t):
    n, = read()
    print (n + 1) / 2


read = lambda : map(int, raw_input().split())

t, = read()

for _ in xrange(t):
    n, = read()
    if n == 1:
        print 1
    else:
        print n / 2


for _ in range(input()):
    print (input()+1)/2


for i in xrange(input()):
    c = input()
    print c//2 if c % 2 == 0  else c//2 + 1


for i in xrange(input()):
    c = input()
    if c <=2:
        print 1
    elif c == 3:
        print 2
    else:
        print c//2


import numpy as np

n = raw_input()
n = int(n)
ll = []
for i in range(n):
    c = raw_input()
    ll.append(int(c))
for i in range(n):
    print((ll[i] + 1) / 2)


n = raw_input()
n = int(n)
ll = []
for i in range(n):
    c = raw_input()
    ll.append(int(c))
for i in range(n):
    print((ll[i] + 1) / 2)


t=int(raw_input())
for r in range(t):
    n = int(raw_input())
    if n<=2:
        print 1
    else:
        if n%2==0:
            print n//2
        else:
            print ((n-1)//2)+1


__author__ = 'Devesh Bajpai'

'''
https://codeforces.com/problemset/problem/1371/A

Solution:
'''

def solve(n):

    return (n + 1)/2

if __name__ == "__main__":

    t = int(raw_input())

    results = list()
    for _ in xrange(0, t):
        n = int(raw_input())
        results.append(solve(n))

    for result in results:
        print result


__author__ = 'Devesh Bajpai'

'''
https://codeforces.com/problemset/problem/1371/A

Solution:
'''

def solve(n):

    if n == 1:
        return 1

    if n == 3:
        return 2

    return n/2

if __name__ == "__main__":

    t = int(raw_input())

    results = list()
    for _ in xrange(0, t):
        n = int(raw_input())
        results.append(solve(n))

    for result in results:
        print result


k=[]
for i in range(int(raw_input())):
    n=int(raw_input())
    k.append(((n-1)//2)+1)

for j in k:
    print(j)


for i in range(input()):
    print ((input() + 1) / 2)


import math
for _ in range(input()):
    n = input()
    print int(math.ceil(float(n)/2))


n = int(raw_input())
for _ in range(n):
	m = int(raw_input())
	print (m + 1) // 2


t = int(input())

while(t>0):
	n = input()
	out = 0
	if(n%2 == 0):
		out = n/2
	else:
		out = (n/2) + 1
	print(out)
	t -= 1


for i in range(int(raw_input())):
	n = int(raw_input())
	if(n%2 == 0):
		print (n/2)
	else:
		print ((n-1)/2) + 1


for _ in xrange(int(raw_input())):
   print (input() + 1) / 2


#include<stdio.h>
int main(){
long long int i,n,k,t,j,l;
scanf("%lld",&t);
for(i=0;i<t;i++){
scanf("%lld",&n);
if(n%2==1){
k=n/2+1;
}

else{
    k=n/2;
}
printf("%lld\n",k);}}


#include<stdio.h>
int main()
{
    int t,n,i,p,s,r;
    scanf("%d",&t);
    for(i=0;i<t;i++)
    {
        scanf("%d",&p);
        if(p==1)
        {
            printf("%d\n",1);
        }
        else if(p%2==0)
        {
          s=p/2;

           printf("%d\n",s);
        }
        else
        {
            s=p/2;
           r=s+1;
           printf("%d\n",r);
        }

    }
}


#include<stdio.h>
int main()
{
				int t,i;
				long long int n;
				scanf("%d",&t);
				for(i=1;i<=t;i++)
				{
								scanf("%lld",&n);
								if(n%2==0)
								{
												printf("%lld",(n/2));
								}
								else
								{
												printf("%lld",(n/2)+1);
								}
				}
				return 0;
}


#include<stdio.h>
int main()
{
				int t,i;
				long long int n;
				scanf("%d",&t);
				for(i=1;i<=t;i++)
				{
								scanf("%lld",&n);
								if(n%2==0)
								{
												printf("%lld\n",(n/2));
								}
								else
								{
												printf("%lld\n",(n/2)+1);
								}
				}
				return 0;
}


#include<stdio.h>

#include<math.h>

int main()
{
    int t,i;
    double a,b;
    scanf("%d",&t);
    for(i=1;i<=t;i++)
    {
        scanf("%lf",&a);
        b=ceil(a/2);
        printf("%lf\n",b);
    }
    return 0;

}


#include<stdio.h>

#include<math.h>

int main()
{
    int t,i;
    double a,b;
    scanf("%d",t);
    for(i=1;i<=t;i++)
    {
        scanf("%lf",&a);
        b=ceil(a/2);
        printf("%lf\n",b);
    }
    return 0;

}


#include<stdio.h>

#include<math.h>

int main()
{
    int t,i,b;
    double a;
    scanf("%d",&t);
    for(i=1;i<=t;i++)
    {
        scanf("%lf",&a);
        b=ceil(a/2);
        printf("%d\n",b);
    }
    return 0;

}


#include<stdio.h>

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        scanf("%d",&n);
        if(n==1||n==2)
        printf("1\n");
        else if(n==3)
        printf("2\n");
        else
        printf("%d\n",n/2);
    }
    return 0;
}


#include<stdio.h>
void main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        long long int n;
        scanf("%lld",&n);
        if(n%2==0)
        printf("%d\n",n/2);
        else
        printf("%d\n",1+n/2);
    }
}


#include<stdio.h>

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        long long int n;
        scanf("%lld",&n);
        if(n==1||n==2)
        printf("1\n");
        else if(n==3)
        printf("2\n");
        else
        printf("%lld\n",n/2);
    }
    return 0;
}


#include<stdio.h>
void main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        long long int n;
        scanf("%lld",&n);
        n%2==0?printf("%d\n",n/2):printf("%d\n",1+n/2)
    }
}


#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll,pill>
#define ld long double
#define F first
#define S second.first
#define T second.second

using namespace std;

const ll N = 1;
const ll big = 6e18;
ll block = 800;
const ll mod = 1e6;

ll n;

set<pill> a;

vector<triple> t;

set<triple> cht;

vector<pill> convex;

ld cross(pill a,pill b){
    return (b.s - a.s + 0.0) / (a.f - b.f + 0.0);
}

void add(pill a){
	while(convex.size() > 1 && cross(a, convex[convex.size() - 2]) >= cross(a, convex.back()))
		convex.pop_back();
	convex.pb(a);
}

int main() {
    speed;
    cin >> n;
    t.pb({0, {0, 0}});
    rep(0, n, 1) {
    	ll x, a, b = 0;
    	cin >> x >> a;
    	if(x == 1)
    		cin >> b;
		t.pb({x, {a, b}});
	}
	block = 4950;

	for(int i = 1; i <= n; i += block) {
		ll l = i, r = min(i + block, n + 1);

		set<triple> sub;

		for(int j = l; j < r; j++) {
			if(t[j].F == 2 && t[j].S < l) {
				triple del = {t[t[j].S].S, {t[t[j].S].T, t[j].S}};
				auto it = cht.find(del);
				cht.erase(it);
				sub.insert(del);
			}
		}
		for(auto u : cht)
			add({u.F,u.S});
		for(int j = l; j < r; j++) {
			if(t[j].F == 1) {
				cht.insert({t[j].S, {t[j].T, j}});
				sub.insert({t[j].S, {t[j].T, j}});
			}
			if(t[j].F == 2) {
				ll L = t[j].S;
				triple del = {t[L].S, { t[L].T, L}};
				auto it = sub.find(del);
				sub.erase(it);
				if(L >= l) {
					it = cht.find(del);
					cht.erase(it);
				}
			}
			if(t[j].F == 3) {
				ll ans = -big;
				if(sub.size() == 0 && cht.size() == 0) {
					cout << "EMPTY SET\n";
					continue;
				}
				ll x = t[j].S;
				for(auto u : sub)
					ans = max(ans, u.F * x + u.S);
				if(convex.size() > 0) {
					ll L = 1, R = convex.size() - 1;
					ans = max(convex[0].f * x + convex[0].s, ans);
					ld XX = x;
					while(L <= R) {
						ll m = (L + R) >> 1;
						ans = max(convex[m].f * x + convex[m].s, ans);
						if(cross(convex[m], convex[m - 1]) > XX)
							R = m - 1;
						else
							L = m + 1;
					}
				}
				cout << ans << '\n';
			}
		}

		convex.clear();
	}

}

/*
x
*/


#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll,pill>
#define ld long double
#define F first
#define S second.first
#define T second.second

using namespace std;

const ll N = 1;
const ll big = 6e18;
ll block = 800;
const ll mod = 1e6;

ll n;

set<pill> a;

vector<triple> t;

set<triple> cht;

vector<pill> convex;

ld cross(pill a,pill b){
    return (b.s - a.s + 0.0) / (a.f - b.f + 0.0);
}

void add(pill a){
    ll szs = sz(convex);
    while(sz(convex) > 1){
        if(cross(a , convex[szs - 2]) > cross(convex[szs - 1] , convex[szs - 2]) )
            break;
        convex.pop_back();
        szs = sz(convex);
    }
    convex.pb(a);
}

int main() {
    speed;
    cin >> n;
    t.pb({0, {0, 0}});
    rep(0, n, 1) {
    	ll x, a, b = 0;
    	cin >> x >> a;
    	if(x == 1)
    		cin >> b;
		t.pb({x, {a, b}});
	}
	block = 500;

	for(int i = 1; i <= n; i += block) {
		ll l = i, r = min(i + block, n + 1);

		set<triple> sub;

		for(int j = l; j < r; j++) {
			if(t[j].F == 2 && t[j].S < l) {
				triple del = {t[t[j].S].S, {t[t[j].S].T, t[j].S}};
				auto it = cht.find(del);
				cht.erase(it);
				sub.insert(del);
			}
		}
		for(auto u : cht)
			add({u.F,u.S});
		for(int j = l; j < r; j++) {
			if(t[j].F == 1) {
				cht.insert({t[j].S, {t[j].T, j}});
				sub.insert({t[j].S, {t[j].T, j}});
			}
			if(t[j].F == 2) {
				ll L = t[j].S;
				triple del = {t[L].S, { t[L].T, L}};
				auto it = sub.find(del);
				sub.erase(it);
				if(L >= l) {
					it = cht.find(del);
					cht.erase(it);
				}
			}
			if(t[j].F == 3) {
				ll ans = -big;
				if(sub.size() == 0 && cht.size() == 0) {
					cout << "EMPTY SET\n";
					continue;
				}
				ll x = t[j].S;
				for(auto u : sub)
					ans = max(ans, u.F * x + u.S);
				if(convex.size() > 0) {
					ll L = 0, R = convex.size() - 2;
					ans = max(convex[n - 1].f * x + convex[0].s, ans);
					ld XX = x;
					while(L <= R) {
						ll m = (L + R) >> 1;
						ans = max(convex[m].f * x + convex[m].s, ans);
						if(cross(convex[m], convex[m - 1]) > XX)
							R = m - 1;
						else
							L = m + 1;
					}
				}
				cout << ans << '\n';
			}
		}

		convex.clear();
	}

}

/*
x
*/


#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll,pill>
#define ld long double
#define F first
#define S second.first
#define T second.second

using namespace std;

const ll N = 1;
const ll big = 6e18;
ll block = 800;
const ll mod = 1e6;

ll n;

set<pill> a;

vector<triple> t;

set<triple> cht;

vector<pill> convex;

ld cross(pill a,pill b){
    return (b.s - a.s + 0.0) / (a.f - b.f + 0.0);
}

void add(pill a){
    ll szs = sz(convex);
    while(sz(convex) > 1){
        if(cross(a , convex[szs - 2]) > cross(convex[szs - 1] , convex[szs - 2]) )
            break;
        convex.pop_back();
        szs = sz(convex);
    }
    convex.pb(a);
}

int main() {
    speed;
    cin >> n;
    t.pb({0, {0, 0}});
    rep(0, n, 1) {
    	ll x, a, b = 0;
    	cin >> x >> a;
    	if(x == 1)
    		cin >> b;
		t.pb({x, {a, b}});
	}
	block = 500;

	for(int i = 1; i <= n; i += block) {
		ll l = i, r = min(i + block, n + 1);

		set<triple> sub;

		for(int j = l; j < r; j++) {
			if(t[j].F == 2 && t[j].S < l) {
				triple del = {t[t[j].S].S, {t[t[j].S].T, t[j].S}};
				auto it = cht.find(del);
				cht.erase(it);
				sub.insert(del);
			}
		}
		for(auto u : cht)
			add({u.F,u.S});
		for(int j = l; j < r; j++) {
			if(t[j].F == 1) {
				cht.insert({t[j].S, {t[j].T, j}});
				sub.insert({t[j].S, {t[j].T, j}});
			}
			if(t[j].F == 2) {
				ll L = t[j].S;
				triple del = {t[L].S, { t[L].T, L}};
				auto it = sub.find(del);
				sub.erase(it);
				if(L >= l) {
					it = cht.find(del);
					cht.erase(it);
				}
			}
			if(t[j].F == 3) {
				ll ans = -big;
				if(sub.size() == 0 && cht.size() == 0) {
					cout << "EMPTY SET\n";
					continue;
				}
				ll x = t[j].S;
				for(auto u : sub)
					ans = max(ans, u.F * x + u.S);
				if(convex.size() > 0) {
					ans = max(convex[0].f * x + convex[0].s, ans);
					ll L = 1, R = convex.size() - 1;
					ld XX = x;
					while(L <= R) {
						ll m = (L + R) >> 1;
						ans = max(convex[m].f * x + convex[m].s, ans);
						if(cross(convex[m], convex[m - 1]) > XX)
							r = m - 1;
						else
							l = m + 1;
					}
				}
				cout << ans << '\n';
			}
		}

		convex.clear();
	}

}

/*
x
*/


#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll,pill>
#define ld long double

using namespace std;

const ll N = 1;
const ll big = 1e18;
const ll block = 800;
const ll mod = 1e6;

ll n;

set<pill> a;

vector<triple> x;

multiset<pill> cht;

ld cross(pill a,pill b){
	if(a.f == b.f)
		return big;
	return ((b.s - a.s) / (b.f - a.f));
}

int main() {
    speed;
    cin >> n;
    rep(0, n, 1) {
    	ll t, a, b = 0;
    	cin >> t >> a;
    	if(t == 1)
    		cin >> b;
		x.pb({t, {a, b}});
	}
	ll blocks = 5091;

	for(int i = 0; i < n; i += block) {
		ll y = i;
		multiset<pill> bruh;
		ll r = min(n, y + block);
		for(int j = y; j < r; j++) {
			if(x[j].f == 2){
				ll hm = x[j].s.f - 1;
				pill amir = x[hm].s;
				if(hm < y){
					bruh.insert(amir);
					auto it = cht.find(amir);
					cht.erase(it);
				}
			}
		}
		vector<pill> convex;
		/*
		for(auto u : cht) {
			while(convex.size() > 1 && cross(convex[convex.size() - 2],u) >= cross(convex.back(), u))
				convex.pop_back();
			convex.pb(u);
		}*/
		for(int j = y; j < r; j++) {
			if(x[j].f == 1){
				bruh.insert(x[j].s);// Âåðíî
				cht.insert(x[j].s);
			}
			if(x[j].f == 2){
				ll hm = x[j].s.f - 1;// Âåðíî
				pill amir = x[hm].s;// Âåðíî
				auto it = bruh.find(amir);// Âåðíî
				bruh.erase(it);// Âåðíî
				it = cht.find(amir);// Âåðíî
				cht.erase(it);// Âåðíî
			}
			if(x[j].f == 3) {
				if(bruh.size() == 0 && convex.size() == 0){// Âåðíî
					cout << "EMPTY SET\n";// Âåðíî
					continue;// Âåðíî
				}// Âåðíî
				ll ans = -big;
				for(auto u = bruh.begin() ; u != bruh.end(); u++){// Âåðíî
					ans = max((*u).f * x[j].s.f + (*u).s, ans);// Âåðíî
				}// Âåðíî
				/*
				if(convex.size() > 0){
					ans = max(convex[0].f * x[j].s.f + convex[0].s, ans);
					ll l = 1, r = convex.size() - 1;
					while(l <= r) {
						ll m = (l + r) / 2;
						ld con = cross(convex[m - 1], convex[m]);
						if(con <= x[j].s.f)
							l = m + 1, ans = max(convex[m].f * x[j].s.f + convex[m].s, ans);
						else
							r = m - 1;
					}
				}*/
				cout << ans << '\n';
			}
		}
	}

}

/*
x
*/


#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll,pill>
#define ld long double

using namespace std;

const ll N = 1;
const ll big = 6e18;
const ll block = 800;
const ll mod = 1e6;

ll n;

set<pill> a;

vector<triple> x;

multiset<pill> cht;

ld cross(pill a,pill b){
	if(a.f == b.f)
		return big;
	return ((b.s - a.s + 0.0) / (b.f - a.f + 0.0));
}

int main() {
    speed;
    cin >> n;
    rep(0, n, 1) {
    	ll t, a, b = 0;
    	cin >> t >> a;
    	if(t == 1)
    		cin >> b;
		x.pb({t, {a, b}});
	}
	ll blocks = 100001;

	for(int i = 0; i < n; i += block) {
		ll y = i;
		multiset<pill> bruh;
		ll r = min(n, y + block);
		for(int j = y; j < r; j++) {
			if(x[j].f == 2){
				ll hm = x[j].s.f - 1;
				pill amir = x[hm].s;
				if(hm < y){
					bruh.insert(amir);
					auto it = cht.find(amir);
					cht.erase(it);
				}
			}
		}
		vector<pill> convex;
		for(auto u : cht) {
			while(convex.size() > 1 && cross(convex[convex.size() - 2],u) >= cross(convex.back(), u))
				convex.pop_back();
			convex.pb(u);
		}
		for(int j = y; j < r; j++) {
			if(x[j].f == 1){
				bruh.insert(x[j].s);// Aa?ii
				cht.insert(x[j].s);
			}
			if(x[j].f == 2){
				ll hm = x[j].s.f - 1;// Aa?ii
				pill amir = x[hm].s;// Aa?ii
				auto it = bruh.find(amir);// Aa?ii
				if(it != bruh.end())
					bruh.erase(it);// Aa?ii
				it = cht.find(amir);// Aa?ii
				if(it != cht.end())
					cht.erase(it);// Aa?ii
			}
			if(x[j].f == 3) {
				if(bruh.size() == 0 && convex.size() == 0){// Aa?ii
					cout << "EMPTY SET\n";// Aa?ii
					continue;// Aa?ii
				}// Aa?ii
				ll ans = -big;
				for(auto u : bruh)
					ans = max(ans, u.f * x[j].s.f + u.s);
				if(convex.size() > 0){
					ans = max(convex[0].f * x[j].s.f + convex[0].s, ans);
					ll l = 1, r = convex.size() - 1;
					while(l <= r) {
						ll m = (l + r) / 2;
						ld con = cross(convex[m - 1], convex[m]);
						if(con <= x[j].s.f)
							l = m + 1, ans = max(convex[m].f * x[j].s.f + convex[m].s, ans);
						else
							r = m - 1;
					}
				}
				cout << ans << '\n';
			}
		}
	}

}

/*
x
*/


#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll,pill>
#define ld long double

using namespace std;

const ll N = 1;
const ll big = 6e18;
const ll block = 800;
const ll mod = 1e6;

ll n;

set<pill> a;

vector<triple> x;

multiset<pill> cht;

ld cross(pill a,pill b){
	if(a.f == b.f)
		return big;
	return ((b.s - a.s) / (b.f - a.f));
}

int main() {
    speed;
    cin >> n;
    rep(0, n, 1) {
    	ll t, a, b = 0;
    	cin >> t >> a;
    	if(t == 1)
    		cin >> b;
		x.pb({t, {a, b}});
	}
	ll blocks = sqrt(n) + 1;

	for(int i = 0; i < n; i += block) {
		ll y = i;
		multiset<pill> bruh;
		ll r = min(n, y + block);
		for(int j = y; j < r; j++) {
			if(x[j].f == 2){
				ll hm = x[j].s.f - 1;
				pill amir = x[hm].s;
				if(hm < y){
					bruh.insert(amir);
					auto it = cht.find(amir);
					cht.erase(it);
				}
			}
		}
		vector<pill> convex;
		for(auto u : cht) {
			while(convex.size() > 1 && cross(convex[convex.size() - 2],u) >= cross(convex.back(), u))
				convex.pop_back();
			convex.pb(u);
		}
		for(int j = y; j < r; j++) {
			if(x[j].f == 1){
				bruh.insert(x[j].s);// Âåðíî
				cht.insert(x[j].s);
			}
			if(x[j].f == 2){
				ll hm = x[j].s.f - 1;// Âåðíî
				pill amir = x[hm].s;// Âåðíî
				auto it = bruh.find(amir);// Âåðíî
				if(it != bruh.end())
					bruh.erase(it);// Âåðíî
				it = cht.find(amir);// Âåðíî
				if(it != cht.end())
					cht.erase(it);// Âåðíî
			}
			if(x[j].f == 3) {
				if(bruh.size() == 0 && convex.size() == 0){// Âåðíî
					cout << "EMPTY SET\n";// Âåðíî
					continue;// Âåðíî
				}// Âåðíî
				ll ans = -big;
				for(auto u : bruh)
					ans = max(ans, u.f * x[j].s.f + u.s);
				/*if(convex.size() > 0){
					ans = max(convex[0].f * x[j].s.f + convex[0].s, ans);
					ll l = 1, r = convex.size() - 1;
					while(l <= r) {
						ll m = (l + r) / 2;
						ld con = cross(convex[m - 1], convex[m]);
						if(con <= x[j].s.f)
							l = m + 1, ans = max(convex[m].f * x[j].s.f + convex[m].s, ans);
						else
							r = m - 1;
					}
				}*/
				cout << ans << '\n';
			}
		}
	}

}

/*
x
*/


#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll,pill>
#define ld long double
#define F first
#define S second.first
#define T second.second

using namespace std;

const ll N = 1;
const ll big = 6e18;
ll block = 800;
const ll mod = 1e6;

ll n;

set<pill> a;

vector<triple> t;

set<triple> cht;

vector<pill> convex;

ld cross(pill a,pill b){
    return (b.s - a.s + 0.0) / (a.f - b.f + 0.0);
}

void add(pill a){
	while(convex.size() > 1 && cross(a, convex[convex.size() - 2]) >= cross(a, convex.back()))
		convex.pop_back();
	convex.pb(a);
}

int main() {
    speed;
    cin >> n;
    t.pb({0, {0, 0}});
    rep(0, n, 1) {
    	ll x, a, b = 0;
    	cin >> x >> a;
    	if(x == 1)
    		cin >> b;
		t.pb({x, {a, b}});
	}
	block = 5000;

	for(int i = 1; i <= n; i += block) {
		ll l = i, r = min(i + block, n + 1);

		set<triple> sub;

		for(int j = l; j < r; j++) {
			if(t[j].F == 2 && t[j].S < l) {
				triple del = {t[t[j].S].S, {t[t[j].S].T, t[j].S}};
				auto it = cht.find(del);
				cht.erase(it);
				sub.insert(del);
			}
		}
		for(auto u : cht)
			add({u.F,u.S});
		for(int j = l; j < r; j++) {
			if(t[j].F == 1) {
				cht.insert({t[j].S, {t[j].T, j}});
				sub.insert({t[j].S, {t[j].T, j}});
			}
			if(t[j].F == 2) {
				ll L = t[j].S;
				triple del = {t[L].S, { t[L].T, L}};
				auto it = sub.find(del);
				sub.erase(it);
				if(L >= l) {
					it = cht.find(del);
					cht.erase(it);
				}
			}
			if(t[j].F == 3) {
				ll ans = -big;
				if(sub.size() == 0 && cht.size() == 0) {
					cout << "EMPTY SET\n";
					continue;
				}
				ll x = t[j].S;
				for(auto u : sub)
					ans = max(ans, u.F * x + u.S);
				if(convex.size() > 0) {
					ll L = 1, R = convex.size() - 1;
					ans = max(convex[0].f * x + convex[0].s, ans);
					ld XX = x;
					while(L <= R) {
						ll m = (L + R) >> 1;
						ans = max(convex[m].f * x + convex[m].s, ans);
						if(cross(convex[m], convex[m - 1]) > XX)
							R = m - 1;
						else
							L = m + 1;
					}
				}
				cout << ans << '\n';
			}
		}

		convex.clear();
	}

}

/*
x
*/


#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll,pill>
#define ld long double
#define F first
#define S second.first
#define T second.second

using namespace std;

const ll N = 1;
const ll big = 6e18;
ll block = 800;
const ll mod = 1e6;

ll n;

set<pill> a;

vector<triple> t;

set<triple> cht;

vector<pill> convex;

ld cross(pill a,pill b){
    return (b.s - a.s + 0.0) / (a.f - b.f + 0.0);
}

void add(pill a){
    ll szs = sz(convex);
    while(sz(convex) > 1){
        if(cross(a , convex[szs - 2]) > cross(convex[szs - 1] , convex[szs - 2]) )
            break;
        convex.pop_back();
        szs = sz(convex);
    }
    convex.pb(a);
}

int main() {
    speed;
    cin >> n;
    t.pb({0, {0, 0}});
    rep(0, n, 1) {
    	ll x, a, b = 0;
    	cin >> x >> a;
    	if(x == 1)
    		cin >> b;
		t.pb({x, {a, b}});
	}
	block = 1000;

	for(int i = 1; i <= n; i += block) {
		ll l = i, r = min(i + block, n + 1);

		set<triple> sub;

		for(int j = l; j < r; j++) {
			if(t[j].F == 2 && t[j].S < l) {
				triple del = {t[t[j].S].S, {t[t[j].S].T, t[j].S}};
				auto it = cht.find(del);
				cht.erase(it);
				sub.insert(del);
			}
		}
		for(auto u : cht)
			add({u.F,u.S});
		for(int j = l; j < r; j++) {
			if(t[j].F == 1) {
				cht.insert({t[j].S, {t[j].T, j}});
				sub.insert({t[j].S, {t[j].T, j}});
			}
			if(t[j].F == 2) {
				ll L = t[j].S;
				triple del = {t[L].S, { t[L].T, L}};
				auto it = sub.find(del);
				sub.erase(it);
				if(L >= l) {
					it = cht.find(del);
					cht.erase(it);
				}
			}
			if(t[j].F == 3) {
				ll ans = -big;
				if(sub.size() == 0 && cht.size() == 0) {
					cout << "EMPTY SET\n";
					continue;
				}
				ll x = t[j].S;
				for(auto u : sub)
					ans = max(ans, u.F * x + u.S);
				if(convex.size() > 0) {
					ll L = 1, R = convex.size() - 1;
					ans = max(convex[0].f * x + convex[0].s, ans);
					ld XX = x;
					while(L <= R) {
						ll m = (L + R) >> 1;
						ans = max(convex[m].f * x + convex[m].s, ans);
						if(cross(convex[m], convex[m - 1]) > XX)
							R = m - 1;
						else
							L = m + 1;
					}
				}
				cout << ans << '\n';
			}
		}

		convex.clear();
	}

}

/*
x
*/


#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll,pill>
#define ld long double
#define F first
#define S second.first
#define T second.second

using namespace std;

const ll N = 1;
const ll big = 6e18;
ll block = 800;
const ll mod = 1e6;

ll n;

set<pill> a;

vector<triple> t;

set<triple> cht;

vector<pill> convex;

ld cross(pill a,pill b){
    return (b.s - a.s + 0.0) / (a.f - b.f + 0.0);
}

void add(pill a){
    ll szs = sz(convex);
    while(sz(convex) > 1){
        if(cross(a , convex[szs - 2]) > cross(convex[szs - 1] , convex[szs - 2]) )
            break;
        convex.pop_back();
        szs = sz(convex);
    }
    convex.pb(a);
}

int main() {
    speed;
    cin >> n;
    t.pb({0, {0, 0}});
    rep(0, n, 1) {
    	ll x, a, b = 0;
    	cin >> x >> a;
    	if(x == 1)
    		cin >> b;
		t.pb({x, {a, b}});
	}
	block = 3000;

	for(int i = 1; i <= n; i += block) {
		ll l = i, r = min(i + block, n + 1);

		set<triple> sub;

		for(int j = l; j < r; j++) {
			if(t[j].F == 2 && t[j].S < l) {
				triple del = {t[t[j].S].S, {t[t[j].S].T, t[j].S}};
				auto it = cht.find(del);
				cht.erase(it);
				sub.insert(del);
			}
		}
		for(auto u : cht)
			add({u.F,u.S});
		for(int j = l; j < r; j++) {
			if(t[j].F == 1) {
				cht.insert({t[j].S, {t[j].T, j}});
				sub.insert({t[j].S, {t[j].T, j}});
			}
			if(t[j].F == 2) {
				ll L = t[j].S;
				triple del = {t[L].S, { t[L].T, L}};
				auto it = sub.find(del);
				sub.erase(it);
				if(L >= l) {
					it = cht.find(del);
					cht.erase(it);
				}
			}
			if(t[j].F == 3) {
				ll ans = -big;
				if(sub.size() == 0 && cht.size() == 0) {
					cout << "EMPTY SET\n";
					continue;
				}
				ll x = t[j].S;
				for(auto u : sub)
					ans = max(ans, u.F * x + u.S);
				if(convex.size() > 0) {
					ll L = 1, R = convex.size() - 1;
					ans = max(convex[0].f * x + convex[0].s, ans);
					ld XX = x;
					while(L <= R) {
						ll m = (L + R) >> 1;
						ans = max(convex[m].f * x + convex[m].s, ans);
						if(cross(convex[m], convex[m - 1]) > XX)
							R = m - 1;
						else
							L = m + 1;
					}
				}
				cout << ans << '\n';
			}
		}

		convex.clear();
	}

}

/*
x
*/


#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll,pill>
#define ld long double

using namespace std;

const ll N = 1;
const ll big = 1e18;
const ll block = 800;
const ll mod = 1e6;

ll n;

set<pill> a;

vector<triple> x;

multiset<pill> cht;

ld cross(pill a,pill b){
	if(a.f == b.f)
		return big;
	return ((b.s - a.s) / (b.f - a.f));
}

int main() {
    speed;
    cin >> n;
    rep(0, n, 1) {
    	ll t, a, b = 0;
    	cin >> t >> a;
    	if(t == 1)
    		cin >> b;
		x.pb({t, {a, b}});
	}
	ll blocks = 5091;

	for(int i = 0; i < n; i += block) {
		ll y = i;
		multiset<pill> bruh;
		ll r = min(n, y + block);
		/*for(int j = y; j < r; j++) {
			if(x[j].f == 2){
				ll hm = x[j].s.f - 1;
				pill amir = x[hm].s;
				if(hm < y){
					bruh.insert(amir);
					auto it = cht.find(amir);
					cht.erase(it);
				}
			}
		}*/
		vector<pill> convex;
		/*
		for(auto u : cht) {
			while(convex.size() > 1 && cross(convex[convex.size() - 2],u) >= cross(convex.back(), u))
				convex.pop_back();
			convex.pb(u);
		}*/
		for(int j = y; j < r; j++) {
			if(x[j].f == 1){
				bruh.insert(x[j].s);// Âåðíî
				cht.insert(x[j].s);
			}
			if(x[j].f == 2){
				ll hm = x[j].s.f - 1;// Âåðíî
				pill amir = x[hm].s;// Âåðíî
				auto it = bruh.find(amir);// Âåðíî
				bruh.erase(it);// Âåðíî
				it = cht.find(amir);// Âåðíî
				cht.erase(it);// Âåðíî
			}
			if(x[j].f == 3) {
				if(bruh.size() == 0 && convex.size() == 0){// Âåðíî
					cout << "EMPTY SET\n";// Âåðíî
					continue;// Âåðíî
				}// Âåðíî
				ll ans = -big;
				for(auto u = bruh.begin() ; u != bruh.end(); u++){// Âåðíî
					ans = max((*u).f * x[j].s.f + (*u).s, ans);// Âåðíî
				}// Âåðíî
				/*
				if(convex.size() > 0){
					ans = max(convex[0].f * x[j].s.f + convex[0].s, ans);
					ll l = 1, r = convex.size() - 1;
					while(l <= r) {
						ll m = (l + r) / 2;
						ld con = cross(convex[m - 1], convex[m]);
						if(con <= x[j].s.f)
							l = m + 1, ans = max(convex[m].f * x[j].s.f + convex[m].s, ans);
						else
							r = m - 1;
					}
				}*/
				cout << ans << '\n';
			}
		}
	}

}

/*
x
*/


#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll,pill>
#define ld long double

using namespace std;

const ll N = 1;
const ll big = 1e18;
const ll block = 800;
const ll mod = 1e6;

ll n;

set<pill> a;

vector<triple> x;

multiset<pill> cht;

ld cross(pill a,pill b){
	if(a.f == b.f)
		return big;
	return ((b.s - a.s) / (b.f - a.f));
}

int main() {
    speed;
    cin >> n;	// Âåðíî
    rep(0, n, 1) {// Âåðíî
    	ll t, a, b = 0;// Âåðíî
    	cin >> t >> a;// Âåðíî
    	if(t == 1) // Âåðíî
    		cin >> b;// Âåðíî
		x.pb({t, {a, b}});// Âåðíî
	}
	ll blocks = 1;// Âåðíî

	for(int i = 0; i < n; i += block) {// Âåðíî
		if( i >= 1000){
			cout << "daun\n";
			ex;
		}
		ll y = i;// Âåðíî
		multiset<pill> bruh;// Âåðíî
		ll r = min(n, y + block);// Âåðíî
		for(int j = y; j < r; j++) {// Âåðíî
			if(x[j].f == 2){// Âåðíî
				ll hm = x[j].s.f - 1;// Âåðíî
				pill amir = x[hm].s;// Âåðíî
				if(hm < y){// Âåðíî
					bruh.insert(amir);// Âåðíî
					auto it = cht.find(amir);// Âåðíî
					cht.erase(it);// Âåðíî
				}// Âåðíî
			}// Âåðíî
		}// Âåðíî
		// Íåèçâåñòíî
		vector<pill> convex;
		for(auto u : cht) {
			while(convex.size() > 1 && cross(convex[convex.size() - 2],u) >= cross(convex.back(), u))
				convex.pop_back();
			convex.pb(u);
		}
		// Íåèçâåñòíî
		for(int j = y; j < r; j++) {
			if(x[j].f == 1){
				bruh.insert(x[j].s);// Âåðíî
				cht.insert(x[j].s);// Âåðíî
			}
			if(x[j].f == 2){
				ll hm = x[j].s.f - 1;// Âåðíî
				pill amir = x[hm].s;// Âåðíî
				auto it = bruh.find(amir);// Âåðíî
				bruh.erase(it);// Âåðíî
				it = cht.find(amir);// Âåðíî
				cht.erase(it);// Âåðíî
			}
			if(x[j].f == 3) {
				if(bruh.size() == 0 && convex.size() == 0){// Âåðíî
					cout << "EMPTY SET\n";// Âåðíî
					continue;// Âåðíî
				}// Âåðíî
				ll ans = -big;
				for(auto u : bruh) {// Âåðíî
					ans = max(u.f * x[j].s.f + u.s, ans);// Âåðíî
				}// Âåðíî
				if(convex.size() > 0){
					ans = max(convex[0].f * x[j].s.f + convex[0].s, ans);
					ll l = 1, r = convex.size() - 1;
					while(l <= r) {
						ll m = (l + r) / 2;
						ld con = cross(convex[m - 1], convex[m]);
						if(con <= x[j].s.f)
							l = m + 1, ans = max(convex[m].f * x[j].s.f + convex[m].s, ans);
						else
							r = m - 1;
					}
				}
				cout << ans << '\n';
			}
		}
	}

}

/*
x
*/


#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll,pill>
#define ld long double

using namespace std;

const ll N = 1;
const ll big = 1e18;
const ll block = 800;
const ll mod = 1e6;

ll n;

set<pill> a;

vector<triple> x;

multiset<pill> cht;

ld cross(pill a,pill b){
	if(a.f == b.f)
		return big;
	return ((b.s - a.s) / (b.f - a.f));
}

int main() {
    speed;
    cin >> n;	// Верно
    rep(0, n, 1) {// Верно
    	ll t, a, b = 0;// Верно
    	cin >> t >> a;// Верно
    	if(t == 1) // Верно
    		cin >> b;// Верно
		x.pb({t, {a, b}});// Верно
	}
	ll blocks = 1000;// Верно

	for(int i = 0; i < n; i += block) {// Верно
		ll y = i;// Верно
		multiset<pill> bruh;// Верно
		ll r = min(n, y + block);// Верно
		for(int j = y; j < r; j++) {// Верно
			if(x[j].f == 2){// Верно
				ll hm = x[j].s.f - 1;// Верно
				pill amir = x[hm].s;// Верно
				if(hm < y){// Верно
					bruh.insert(amir);// Верно
					auto it = cht.find(amir);// Верно
					cht.erase(it);// Верно
				}// Верно
			}// Верно
		}// Верно
		// Неизвестно
		vector<pill> convex;
		for(auto u : cht) {
			while(convex.size() > 1 && cross(convex[convex.size() - 2],u) >= cross(convex.back(), u))
				convex.pop_back();
			convex.pb(u);
		}
		// Неизвестно
		for(int j = y; j < r; j++) {
			if(x[j].f == 1){
				bruh.insert(x[j].s);// Верно
				cht.insert(x[j].s);// Верно
			}
			if(x[j].f == 2){
				ll hm = x[j].s.f - 1;// Верно
				pill amir = x[hm].s;// Верно
				auto it = bruh.find(amir);// Верно
				bruh.erase(it);// Верно
				it = cht.find(amir);// Верно
				cht.erase(it);// Верно
			}
			if(x[j].f == 3) {
				if(bruh.size() == 0 && convex.size() == 0){// Верно
					cout << "EMPTY SET\n";// Верно
					continue;// Верно
				}// Верно
				ll ans = -big;
				for(auto u : bruh) {// Верно
					ans = max(u.f * x[j].s.f + u.s, ans);// Верно
				}// Верно
				if(convex.size() > 0){
					ans = max(convex[0].f * x[j].s.f + convex[0].s, ans);
					ll l = 1, r = convex.size() - 1;
					while(l <= r) {
						ll m = (l + r) / 2;
						ld con = cross(convex[m - 1], convex[m]);
						if(con <= x[j].s.f)
							l = m + 1, ans = max(convex[m].f * x[j].s.f + convex[m].s, ans);
						else
							r = m - 1;
					}
				}
				cout << ans << '\n';
			}
		}
	}

}

/*
x
*/


#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll,pill>
#define ld long double
#define F first
#define S second.first
#define T second.second

using namespace std;

const ll N = 1;
const ll big = 6e18;
ll block = 800;
const ll mod = 1e6;

ll n;

set<pill> a;

vector<triple> t;

set<triple> cht;

vector<pill> convex;

ld cross(pill a,pill b){
	if(a.f == b.f)
		return big;
	return (((ld)b.s - (ld)a.s) / ((ld)b.f - (ld)a.f));
}

void add(pill a){
	while(convex.size() > 1 && cross(a, convex[convex.size() - 2]) >= cross(a, convex.back()))
		convex.pop_back();
	convex.pb(a);
}

int main() {
    speed;
    cin >> n;
    t.pb({0, {0, 0}});
    rep(0, n, 1) {
    	ll x, a, b = 0;
    	cin >> x >> a;
    	if(x == 1)
    		cin >> b;
		t.pb({x, {a, b}});
	}
	block = sqrt(n);

	for(int i = 1; i <= n; i += block) {
		ll l = i, r = min(i + block, n + 1);

		set<triple> sub;

		for(int j = l; j < r; j++) {
			if(t[j].F == 2 && t[j].S < l) {
				triple del = {t[t[j].S].S, {t[t[j].S].T, t[j].S}};
				auto it = cht.find(del);
				cht.erase(it);
				sub.insert(del);
			}
		}

		for(auto u : cht)
			add({u.F,u.S});

		for(int j = l; j < r; j++) {
			if(t[j].F == 1) {
				cht.insert({t[j].S, {t[j].T, j}});
				sub.insert({t[j].S, {t[j].T, j}});
			}
			if(t[j].F == 2) {
				ll L = t[j].S;
				triple del = {t[L].S, { t[L].T, L}};
				auto it = sub.find(del);
				sub.erase(it);
				if(L >= l) {
					it = cht.find(del);
					cht.erase(it);
				}
			}
			if(t[j].F == 3) {
				ll ans = -big;
				if(sub.size() == 0 && cht.size() == 0) {
					cout << "EMPTY SET\n";
					continue;
				}
				ll x = t[j].S;
				for(auto u : sub)
					ans = max(ans, u.F * x + u.S);
				if(convex.size() > 0) {
					ans = max(convex[0].f * x + convex[0].s, ans);
					ll L = 1, R = convex.size() - 1;
					ld XX = x;
					while(L <= R) {
						ll m = (L + R) >> 1;
						ans = max(convex[m].f * x + convex[m].s, ans);
						if(cross(convex[m], convex[m - 1]) > XX)
							r = m - 1;
						else
							l = m + 1;
					}
				}
				cout << ans << '\n';
			}
		}

		convex.clear();
	}

}

/*
x
*/


#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll,pill>
#define ld long double

using namespace std;

const ll N = 1;
const ll big = 6e18;
const ll block = 800;
const ll mod = 1e6;

ll n;

set<pill> a;

vector<triple> x;

multiset<pill> cht;

ld cross(pill a,pill b){
	if(a.f == b.f)
		return big;
	return ((b.s - a.s + 0.0) / (b.f - a.f + 0.0));
}

int main() {
    speed;
    cin >> n;
    rep(0, n, 1) {
    	ll t, a, b = 0;
    	cin >> t >> a;
    	if(t == 1)
    		cin >> b;
		x.pb({t, {a, b}});
	}
	ll blocks = 100001;

	for(int i = 0; i < n; i += block) {
		ll y = i;
		multiset<pill> bruh;
		ll r = min(n, y + block);
		for(int j = y; j < r; j++) {
			if(x[j].f == 2){
				ll hm = x[j].s.f - 1;
				pill amir = x[hm].s;
				if(hm < y){
					bruh.insert(amir);
					auto it = cht.find(amir);
					cht.erase(it);
				}
			}
		}
		vector<pill> convex;
		for(auto u : cht) {
			while(convex.size() > 1 && cross(convex[convex.size() - 2],u) >= cross(convex.back(), u))
				convex.pop_back();
			convex.pb(u);
		}
		for(int j = y; j < r; j++) {
			if(x[j].f == 1){
				bruh.insert(x[j].s);// Aa?ii
				cht.insert(x[j].s);
			}
			if(x[j].f == 2){
				ll hm = x[j].s.f - 1;// Aa?ii
				pill amir = x[hm].s;// Aa?ii
				auto it = bruh.find(amir);// Aa?ii
				if(it != bruh.end())
					bruh.erase(it);// Aa?ii
				it = cht.find(amir);// Aa?ii
				if(it != cht.end())
					cht.erase(it);// Aa?ii
			}
			if(x[j].f == 3) {
				if(bruh.size() == 0 && convex.size() == 0){// Aa?ii
					cout << "EMPTY SET\n";// Aa?ii
					continue;// Aa?ii
				}// Aa?ii
				ll ans = -big;
				for(auto u : bruh)
					ans = max(ans, u.f * x[j].s.f + u.s);
				if(convex.size() > 0){
				    if(convex.size() == 1 || cross(convex[0],convex[1]) >= x[j].s.f)
					    ans = max(convex[0].f * x[j].s.f + convex[0].s, ans);
					ll l = 1, r = convex.size() - 1;
					while(l <= r) {
						ll m = (l + r) / 2;
						ld con = cross(convex[m - 1], convex[m]);
						if(con <= x[j].s.f)
							l = m + 1, ans = max(convex[m].f * x[j].s.f + convex[m].s, ans);
						else
							r = m - 1;
					}
				}
				cout << ans << '\n';
			}
		}
	}

}

/*
x
*/


#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll,pill>
#define ld long double
#define F first
#define S second.first
#define T second.second

using namespace std;

const ll N = 1;
const ll big = 6e18;
ll block = 800;
const ll mod = 1e6;

ll n;

set<pill> a;

vector<triple> t;

set<triple> cht;

vector<pill> convex;

ld cross(pill a,pill b){
    return (b.s - a.s + 0.0) / (a.f - b.f + 0.0);
}

void add(pill a) {
	while(convex.size() >= 2 && cross(x[convex.size() - 2], a) >= cross(convex[convex.size() - 2], convex[convex.size() - 1]))
		convex.pop_back();
	convex.push_back(a);
}

int main() {
    speed;
    cin >> n;
    t.pb({0, {0, 0}});
    rep(0, n, 1) {
    	ll x, a, b = 0;
    	cin >> x >> a;
    	if(x == 1)
    		cin >> b;
		t.pb({x, {a, b}});
	}
	block = 4950;

	for(int i = 1; i <= n; i += block) {
		ll l = i, r = min(i + block, n + 1);

		set<triple> sub;

		for(int j = l; j < r; j++) {
			if(t[j].F == 2 && t[j].S < l) {
				triple del = {t[t[j].S].S, {t[t[j].S].T, t[j].S}};
				auto it = cht.find(del);
				cht.erase(it);
				sub.insert(del);
			}
		}
		for(auto u : cht)
			add({u.F,u.S});
		for(int j = l; j < r; j++) {
			if(t[j].F == 1) {
				cht.insert({t[j].S, {t[j].T, j}});
				sub.insert({t[j].S, {t[j].T, j}});
			}
			if(t[j].F == 2) {
				ll L = t[j].S;
				triple del = {t[L].S, { t[L].T, L}};
				auto it = sub.find(del);
				sub.erase(it);
				if(L >= l) {
					it = cht.find(del);
					cht.erase(it);
				}
			}
			if(t[j].F == 3) {
				ll ans = -big;
				if(sub.size() == 0 && cht.size() == 0) {
					cout << "EMPTY SET\n";
					continue;
				}
				ll x = t[j].S;
				for(auto u : sub)
					ans = max(ans, u.F * x + u.S);
				if(convex.size() > 0) {
					ll L = 1, R = convex.size() - 1;
					ans = max(convex[0].f * x + convex[0].s, ans);
					ld XX = x;
					while(L <= R) {
						ll m = (L + R) >> 1;
						ans = max(convex[m].f * x + convex[m].s, ans);
						if(cross(convex[m], convex[m - 1]) > XX)
							R = m - 1;
						else
							L = m + 1;
					}
				}
				cout << ans << '\n';
			}
		}

		convex.clear();
	}

}

/*
x
*/


#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll,pill>
#define ld long double
#define F first
#define S second.first
#define T second.second

using namespace std;

const ll N = 1;
const ll big = 6e18;
ll block = 800;
const ll mod = 1e6;

ll n;

set<pill> a;

vector<triple> t;

set<triple> cht;

vector<pill> convex;

ld cross(pill a,pill b){
    return (b.s - a.s + 0.0) / (a.f - b.f + 0.0);
}

void add(pill a){
	while(convex.size() > 1 && cross(a, convex[convex.size() - 2]) >= cross(a, convex.back()))
		convex.pop_back();
	convex.pb(a);
}

int main() {
    speed;
    cin >> n;
    t.pb({0, {0, 0}});
    rep(0, n, 1) {
    	ll x, a, b = 0;
    	cin >> x >> a;
    	if(x == 1)
    		cin >> b;
		t.pb({x, {a, b}});
	}
	block = 4850;

	for(int i = 1; i <= n; i += block) {
		ll l = i, r = min(i + block, n + 1);

		set<triple> sub;

		for(int j = l; j < r; j++) {
			if(t[j].F == 2 && t[j].S < l) {
				triple del = {t[t[j].S].S, {t[t[j].S].T, t[j].S}};
				auto it = cht.find(del);
				cht.erase(it);
				sub.insert(del);
			}
		}
		for(auto u : cht)
			add({u.F,u.S});
		for(int j = l; j < r; j++) {
			if(t[j].F == 1) {
				cht.insert({t[j].S, {t[j].T, j}});
				sub.insert({t[j].S, {t[j].T, j}});
			}
			if(t[j].F == 2) {
				ll L = t[j].S;
				triple del = {t[L].S, { t[L].T, L}};
				auto it = sub.find(del);
				sub.erase(it);
				if(L >= l) {
					it = cht.find(del);
					cht.erase(it);
				}
			}
			if(t[j].F == 3) {
				ll ans = -big;
				if(sub.size() == 0 && cht.size() == 0) {
					cout << "EMPTY SET\n";
					continue;
				}
				ll x = t[j].S;
				for(auto u : sub)
					ans = max(ans, u.F * x + u.S);
				if(convex.size() > 0) {
					ll L = 1, R = convex.size() - 1;
					ans = max(convex[0].f * x + convex[0].s, ans);
					ld XX = x;
					while(L <= R) {
						ll m = (L + R) >> 1;
						ans = max(convex[m].f * x + convex[m].s, ans);
						if(cross(convex[m], convex[m - 1]) > XX)
							R = m - 1;
						else
							L = m + 1;
					}
				}
				cout << ans << '\n';
			}
		}

		convex.clear();
	}

}

/*
x
*/


#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll,pill>
#define ld long double
#define F first
#define S second.first
#define T second.second

using namespace std;

const ll N = 1;
const ll big = 6e18;
ll block = 800;
const ll mod = 1e6;

ll n;

set<pill> a;

vector<triple> t;

set<triple> cht;

vector<pill> convex;

ld cross(pill a,pill b){
    return (b.s - a.s + 0.0) / (a.f - b.f + 0.0);
}

void add(pill a){
	while(convex.size() > 1 && cross(a, convex[convex.size() - 2]) >= cross(a, convex.back()))
		convex.pop_back();
	convex.pb(a);
}

int main() {
    speed;
    cin >> n;
    t.pb({0, {0, 0}});
    rep(0, n, 1) {
    	ll x, a, b = 0;
    	cin >> x >> a;
    	if(x == 1)
    		cin >> b;
		t.pb({x, {a, b}});
	}
	block = 5312;

	for(int i = 1; i <= n; i += block) {
		ll l = i, r = min(i + block, n + 1);

		set<triple> sub;

		for(int j = l; j < r; j++) {
			if(t[j].F == 2 && t[j].S < l) {
				triple del = {t[t[j].S].S, {t[t[j].S].T, t[j].S}};
				auto it = cht.find(del);
				cht.erase(it);
				sub.insert(del);
			}
		}
		for(auto u : cht)
			add({u.F,u.S});
		for(int j = l; j < r; j++) {
			if(t[j].F == 1) {
				cht.insert({t[j].S, {t[j].T, j}});
				sub.insert({t[j].S, {t[j].T, j}});
			}
			if(t[j].F == 2) {
				ll L = t[j].S;
				triple del = {t[L].S, { t[L].T, L}};
				auto it = sub.find(del);
				sub.erase(it);
				if(L >= l) {
					it = cht.find(del);
					cht.erase(it);
				}
			}
			if(t[j].F == 3) {
				ll ans = -big;
				if(sub.size() == 0 && cht.size() == 0) {
					cout << "EMPTY SET\n";
					continue;
				}
				ll x = t[j].S;
				for(auto u : sub)
					ans = max(ans, u.F * x + u.S);
				if(convex.size() > 0) {
					ll L = 1, R = convex.size() - 1;
					ans = max(convex[0].f * x + convex[0].s, ans);
					ld XX = x;
					while(L <= R) {
						ll m = (L + R) >> 1;
						ans = max(convex[m].f * x + convex[m].s, ans);
						if(cross(convex[m], convex[m - 1]) > XX)
							R = m - 1;
						else
							L = m + 1;
					}
				}
				cout << ans << '\n';
			}
		}

		convex.clear();
	}

}

/*
x
*/


#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll,pill>
#define ld long double
#define F first
#define S second.first
#define T second.second

using namespace std;

const ll N = 1;
const ll big = 6e18;
ll block = 800;
const ll mod = 1e6;

ll n;

set<pill> a;

vector<triple> t;

set<triple> cht;

vector<pill> convex;

ld cross(pill a,pill b){
    return (b.s - a.s + 0.0) / (a.f - b.f + 0.0);
}

void add(pill a) {
	while(convex.size() >= 2 && cross(x[convex.size() - 2], a) >= cross(convex[convex.size() - 2], convex[convex.size() - 1]))
		convex.pop_back();
	convex.push_back({k, b});
}

int main() {
    speed;
    cin >> n;
    t.pb({0, {0, 0}});
    rep(0, n, 1) {
    	ll x, a, b = 0;
    	cin >> x >> a;
    	if(x == 1)
    		cin >> b;
		t.pb({x, {a, b}});
	}
	block = 4950;

	for(int i = 1; i <= n; i += block) {
		ll l = i, r = min(i + block, n + 1);

		set<triple> sub;

		for(int j = l; j < r; j++) {
			if(t[j].F == 2 && t[j].S < l) {
				triple del = {t[t[j].S].S, {t[t[j].S].T, t[j].S}};
				auto it = cht.find(del);
				cht.erase(it);
				sub.insert(del);
			}
		}
		for(auto u : cht)
			add({u.F,u.S});
		for(int j = l; j < r; j++) {
			if(t[j].F == 1) {
				cht.insert({t[j].S, {t[j].T, j}});
				sub.insert({t[j].S, {t[j].T, j}});
			}
			if(t[j].F == 2) {
				ll L = t[j].S;
				triple del = {t[L].S, { t[L].T, L}};
				auto it = sub.find(del);
				sub.erase(it);
				if(L >= l) {
					it = cht.find(del);
					cht.erase(it);
				}
			}
			if(t[j].F == 3) {
				ll ans = -big;
				if(sub.size() == 0 && cht.size() == 0) {
					cout << "EMPTY SET\n";
					continue;
				}
				ll x = t[j].S;
				for(auto u : sub)
					ans = max(ans, u.F * x + u.S);
				if(convex.size() > 0) {
					ll L = 1, R = convex.size() - 1;
					ans = max(convex[0].f * x + convex[0].s, ans);
					ld XX = x;
					while(L <= R) {
						ll m = (L + R) >> 1;
						ans = max(convex[m].f * x + convex[m].s, ans);
						if(cross(convex[m], convex[m - 1]) > XX)
							R = m - 1;
						else
							L = m + 1;
					}
				}
				cout << ans << '\n';
			}
		}

		convex.clear();
	}

}

/*
x
*/


#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll,pill>
#define ld long double
#define F first
#define S second.first
#define T second.second

using namespace std;

const ll N = 1;
const ll big = 6e18;
ll block = 800;
const ll mod = 1e6;

ll n;

set<pill> a;

vector<triple> t;

set<triple> cht;

vector<pill> convex;

ld cross(pill a,pill b){
    return (b.s - a.s + 0.0) / (a.f - b.f + 0.0);
}

void add(pill a){
	while(convex.size() > 1 && cross(a, convex[convex.size() - 2]) >= cross(a, convex.back()))
		convex.pop_back();
	convex.pb(a);
}

int main() {
    speed;
    cin >> n;
    t.pb({0, {0, 0}});
    rep(0, n, 1) {
    	ll x, a, b = 0;
    	cin >> x >> a;
    	if(x == 1)
    		cin >> b;
		t.pb({x, {a, b}});
	}
	block = 6250;

	for(int i = 1; i <= n; i += block) {
		ll l = i, r = min(i + block, n + 1);

		set<triple> sub;

		for(int j = l; j < r; j++) {
			if(t[j].F == 2 && t[j].S < l) {
				triple del = {t[t[j].S].S, {t[t[j].S].T, t[j].S}};
				auto it = cht.find(del);
				cht.erase(it);
				sub.insert(del);
			}
		}
		for(auto u : cht)
			add({u.F,u.S});
		for(int j = l; j < r; j++) {
			if(t[j].F == 1) {
				cht.insert({t[j].S, {t[j].T, j}});
				sub.insert({t[j].S, {t[j].T, j}});
			}
			if(t[j].F == 2) {
				ll L = t[j].S;
				triple del = {t[L].S, { t[L].T, L}};
				auto it = sub.find(del);
				sub.erase(it);
				if(L >= l) {
					it = cht.find(del);
					cht.erase(it);
				}
			}
			if(t[j].F == 3) {
				ll ans = -big;
				if(sub.size() == 0 && cht.size() == 0) {
					cout << "EMPTY SET\n";
					continue;
				}
				ll x = t[j].S;
				for(auto u : sub)
					ans = max(ans, u.F * x + u.S);
				if(convex.size() > 0) {
					ll L = 1, R = convex.size() - 1;
					ans = max(convex[0].f * x + convex[0].s, ans);
					ld XX = x;
					while(L <= R) {
						ll m = (L + R) >> 1;
						ans = max(convex[m].f * x + convex[m].s, ans);
						if(cross(convex[m], convex[m - 1]) > XX)
							R = m - 1;
						else
							L = m + 1;
					}
				}
				cout << ans << '\n';
			}
		}

		convex.clear();
	}

}

/*
x
*/


#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll,pill>
#define ld long double

using namespace std;

const ll N = 1;
const ll big = 1e18;
const ll block = 800;
const ll mod = 1e6;

ll n;

set<pill> a;

vector<triple> x;

multiset<pill> cht;

ld cross(pill a,pill b){
	if(a.f == b.f)
		return big;
	return ((b.s - a.s) / (b.f - a.f));
}

int main() {
    speed;
    cin >> n;
    rep(0, n, 1) {
    	ll t, a, b = 0;
    	cin >> t >> a;
    	if(t == 1)
    		cin >> b;
		x.pb({t, {a, b}});
	}
	ll blocks = 5091;

	for(int i = 0; i < n; i += block) {
		ll y = i;
		multiset<pill> bruh;
		ll r = min(n, y + block);
		/*for(int j = y; j < r; j++) {
			if(x[j].f == 2){
				ll hm = x[j].s.f - 1;
				pill amir = x[hm].s;
				if(hm < y){
					bruh.insert(amir);
					auto it = cht.find(amir);
					cht.erase(it);
				}
			}
		}*/
		vector<pill> convex;
		/*
		for(auto u : cht) {
			while(convex.size() > 1 && cross(convex[convex.size() - 2],u) >= cross(convex.back(), u))
				convex.pop_back();
			convex.pb(u);
		}*/
		for(int j = y; j < r; j++) {
			if(x[j].f == 1){
				bruh.insert(x[j].s);// Âåðíî
				cht.insert(x[j].s);
			}
			if(x[j].f == 2){
				/*ll hm = x[j].s.f - 1;// Âåðíî
				pill amir = x[hm].s;// Âåðíî
				auto it = bruh.find(amir);// Âåðíî
				bruh.erase(it);// Âåðíî
				it = cht.find(amir);// Âåðíî
				cht.erase(it);// Âåðíî*/
			}
			if(x[j].f == 3) {
				if(bruh.size() == 0 && convex.size() == 0){// Âåðíî
					cout << "EMPTY SET\n";// Âåðíî
					continue;// Âåðíî
				}// Âåðíî
				ll ans = -big;
				for(auto u = bruh.begin() ; u != bruh.end(); u++){// Âåðíî
					ans = max((*u).f * x[j].s.f + (*u).s, ans);// Âåðíî
				}// Âåðíî
				/*
				if(convex.size() > 0){
					ans = max(convex[0].f * x[j].s.f + convex[0].s, ans);
					ll l = 1, r = convex.size() - 1;
					while(l <= r) {
						ll m = (l + r) / 2;
						ld con = cross(convex[m - 1], convex[m]);
						if(con <= x[j].s.f)
							l = m + 1, ans = max(convex[m].f * x[j].s.f + convex[m].s, ans);
						else
							r = m - 1;
					}
				}*/
				cout << ans << '\n';
			}
		}
	}

}

/*
x
*/


#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll,pill>
#define ld long double

using namespace std;

const ll N = 1;
const ll big = 6e18;
const ll block = 800;
const ll mod = 1e6;

ll n;

set<pill> a;

vector<triple> x;

multiset<pill> cht;

ld cross(pill a,pill b){
	if(a.f == b.f)
		return big;
	return ((b.s - a.s) / (b.f - a.f));
}

int main() {
    speed;
    cin >> n;
    rep(0, n, 1) {
    	ll t, a, b = 0;
    	cin >> t >> a;
    	if(t == 1)
    		cin >> b;
		x.pb({t, {a, b}});
	}
	ll blocks = 100001;

	for(int i = 0; i < n; i += blocks) {
		ll y = i;
		multiset<pill> bruh;
		ll r = min(n, y + block);
		for(int j = y; j < r; j++) {
			if(x[j].f == 2){
				ll hm = x[j].s.f - 1;
				pill amir = x[hm].s;
				if(hm < y){
					bruh.insert(amir);
					auto it = cht.find(amir);
					cht.erase(it);
				}
			}
		}
		vector<pill> convex;
		for(auto u : cht) {
			while(convex.size() > 1 && cross(convex[convex.size() - 2],u) >= cross(convex.back(), u))
				convex.pop_back();
			convex.pb(u);
		}
		for(int j = y; j < r; j++) {
			if(x[j].f == 1){
				bruh.insert(x[j].s);// Âåðíî
				cht.insert(x[j].s);
			}
			if(x[j].f == 2){
				ll hm = x[j].s.f - 1;// Âåðíî
				pill amir = x[hm].s;// Âåðíî
				auto it = bruh.find(amir);// Âåðíî
				if(it != bruh.end())
					bruh.erase(it);// Âåðíî
				it = cht.find(amir);// Âåðíî
				if(it != cht.end())
					cht.erase(it);// Âåðíî
			}
			if(x[j].f == 3) {
				if(bruh.size() == 0 && convex.size() == 0){// Âåðíî
					cout << "EMPTY SET\n";// Âåðíî
					continue;// Âåðíî
				}// Âåðíî
				ll ans = -big;
				for(auto u : bruh)
					ans = max(ans, u.f * x[j].s.f + u.s);
				if(convex.size() > 0){
					return -1;
					ans = max(convex[0].f * x[j].s.f + convex[0].s, ans);
					ll l = 1, r = convex.size() - 1;
					while(l <= r) {
						ll m = (l + r) / 2;
						ld con = cross(convex[m - 1], convex[m]);
						if(con <= x[j].s.f)
							l = m + 1, ans = max(convex[m].f * x[j].s.f + convex[m].s, ans);
						else
							r = m - 1;
					}
				}
				cout << ans << '\n';
			}
		}
	}

}

/*
x
*/


#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll,pill>
#define ld long double
#define F first
#define S second.first
#define T second.second

using namespace std;

const ll N = 1;
const ll big = 6e18;
ll block = 800;
const ll mod = 1e6;

ll n;

set<pill> a;

vector<triple> t;

set<triple> cht;

vector<pill> convex;

ld cross(pill a,pill b){
    return (b.s - a.s + 0.0) / (a.f - b.f + 0.0);
}

void add(pill a) {
	while(convex.size() >= 2 && cross(convex[convex.size() - 2], a) >= cross(a, convex[convex.size() - 1]))
		convex.pop_back();
	convex.push_back(a);
}

int main() {
    speed;
    cin >> n;
    t.pb({0, {0, 0}});
    rep(0, n, 1) {
    	ll x, a, b = 0;
    	cin >> x >> a;
    	if(x == 1)
    		cin >> b;
		t.pb({x, {a, b}});
	}
	block = 4950;

	for(int i = 1; i <= n; i += block) {
		ll l = i, r = min(i + block, n + 1);

		set<triple> sub;

		for(int j = l; j < r; j++) {
			if(t[j].F == 2 && t[j].S < l) {
				triple del = {t[t[j].S].S, {t[t[j].S].T, t[j].S}};
				auto it = cht.find(del);
				cht.erase(it);
				sub.insert(del);
			}
		}
		for(auto u : cht)
			add({u.F,u.S});
		for(int j = l; j < r; j++) {
			if(t[j].F == 1) {
				cht.insert({t[j].S, {t[j].T, j}});
				sub.insert({t[j].S, {t[j].T, j}});
			}
			if(t[j].F == 2) {
				ll L = t[j].S;
				triple del = {t[L].S, { t[L].T, L}};
				auto it = sub.find(del);
				sub.erase(it);
				if(L >= l) {
					it = cht.find(del);
					cht.erase(it);
				}
			}
			if(t[j].F == 3) {
				ll ans = -big;
				if(sub.size() == 0 && cht.size() == 0) {
					cout << "EMPTY SET\n";
					continue;
				}
				ll x = t[j].S;
				for(auto u : sub)
					ans = max(ans, u.F * x + u.S);
				if(convex.size() > 0) {
					ll L = 1, R = convex.size() - 1;
					ans = max(convex[0].f * x + convex[0].s, ans);
					ld XX = x;
					while(L <= R) {
						ll m = (L + R) >> 1;
						ans = max(convex[m].f * x + convex[m].s, ans);
						if(cross(convex[m], convex[m - 1]) > XX)
							R = m - 1;
						else
							L = m + 1;
					}
				}
				cout << ans << '\n';
			}
		}

		convex.clear();
	}

}

/*
x
*/


#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll,pill>
#define ld long double

using namespace std;

const ll N = 1;
const ll big = 1e18;
const ll block = 800;
const ll mod = 1e6;

ll n;

set<pill> a;

vector<triple> x;

multiset<pill> cht;

ld cross(pill a,pill b){
	if(a.f == b.f)
		return big;
	return ((b.s - a.s) / (b.f - a.f));
}

int main() {
    speed;
    cin >> n;	// Âåðíî
    rep(0, n, 1) {// Âåðíî
    	ll t, a, b = 0;// Âåðíî
    	cin >> t >> a;// Âåðíî
    	if(t == 1) // Âåðíî
    		cin >> b;// Âåðíî
		x.pb({t, {a, b}});// Âåðíî
	}
	ll blocks = 1;// Âåðíî

	for(int i = 0; i < n; i += block) {// Âåðíî
		if( n == 5000 && i >= 900){
			cout << "daun\n";
			ex;
		}
		ll y = i;// Âåðíî
		multiset<pill> bruh;// Âåðíî
		ll r = min(n, y + block);// Âåðíî
		for(int j = y; j < r; j++) {// Âåðíî
			if(x[j].f == 2){// Âåðíî
				ll hm = x[j].s.f - 1;// Âåðíî
				pill amir = x[hm].s;// Âåðíî
				if(hm < y){// Âåðíî
					bruh.insert(amir);// Âåðíî
					auto it = cht.find(amir);// Âåðíî
					cht.erase(it);// Âåðíî
				}// Âåðíî
			}// Âåðíî
		}// Âåðíî
		// Íåèçâåñòíî
		vector<pill> convex;
		for(auto u : cht) {
			while(convex.size() > 1 && cross(convex[convex.size() - 2],u) >= cross(convex.back(), u))
				convex.pop_back();
			convex.pb(u);
		}
		// Íåèçâåñòíî
		for(int j = y; j < r; j++) {
			if(x[j].f == 1){
				bruh.insert(x[j].s);// Âåðíî
				cht.insert(x[j].s);// Âåðíî
			}
			if(x[j].f == 2){
				ll hm = x[j].s.f - 1;// Âåðíî
				pill amir = x[hm].s;// Âåðíî
				auto it = bruh.find(amir);// Âåðíî
				bruh.erase(it);// Âåðíî
				it = cht.find(amir);// Âåðíî
				cht.erase(it);// Âåðíî
			}
			if(x[j].f == 3) {
				if(bruh.size() == 0 && convex.size() == 0){// Âåðíî
					cout << "EMPTY SET\n";// Âåðíî
					continue;// Âåðíî
				}// Âåðíî
				ll ans = -big;
				for(auto u : bruh) {// Âåðíî
					ans = max(u.f * x[j].s.f + u.s, ans);// Âåðíî
				}// Âåðíî
				if(convex.size() > 0){
					ans = max(convex[0].f * x[j].s.f + convex[0].s, ans);
					ll l = 1, r = convex.size() - 1;
					while(l <= r) {
						ll m = (l + r) / 2;
						ld con = cross(convex[m - 1], convex[m]);
						if(con <= x[j].s.f)
							l = m + 1, ans = max(convex[m].f * x[j].s.f + convex[m].s, ans);
						else
							r = m - 1;
					}
				}
				cout << ans << '\n';
			}
		}
	}

}

/*
x
*/


#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll,pill>
#define ld long double

using namespace std;

const ll N = 1;
const ll big = 6e18;
const ll block = 800;
const ll mod = 1e6;

ll n;

set<pill> a;

vector<triple> x;

multiset<pill> cht;

ld cross(pill a,pill b){
	if(a.f == b.f)
		return -big;
	return ((b.s - a.s + 0.0) / (b.f - a.f + 0.0));
}

int main() {
    speed;
    cin >> n;
    rep(0, n, 1) {
    	ll t, a, b = 0;
    	cin >> t >> a;
    	if(t == 1)
    		cin >> b;
		x.pb({t, {a, b}});
	}
	ll blocks = 100001;

	for(int i = 0; i < n; i += block) {
		ll y = i;
		multiset<pill> bruh;
		ll r = min(n, y + block);
		for(int j = y; j < r; j++) {
			if(x[j].f == 2){
				ll hm = x[j].s.f - 1;
				pill amir = x[hm].s;
				if(hm < y){
					bruh.insert(amir);
					auto it = cht.find(amir);
					cht.erase(it);
				}
			}
		}
		vector<pill> convex;
		for(auto u : cht) {
			while(convex.size() > 1 && cross(convex[convex.size() - 2],u) >= cross(convex.back(), u))
				convex.pop_back();
			convex.pb(u);
		}
		for(int j = y; j < r; j++) {
			if(x[j].f == 1){
				bruh.insert(x[j].s);// Aa?ii
				cht.insert(x[j].s);
			}
			if(x[j].f == 2){
				ll hm = x[j].s.f - 1;// Aa?ii
				pill amir = x[hm].s;// Aa?ii
				auto it = bruh.find(amir);// Aa?ii
				if(it != bruh.end())
					bruh.erase(it);// Aa?ii
				it = cht.find(amir);// Aa?ii
				if(it != cht.end())
					cht.erase(it);// Aa?ii
			}
			if(x[j].f == 3) {
				if(bruh.size() == 0 && convex.size() == 0){// Aa?ii
					cout << "EMPTY SET\n";// Aa?ii
					continue;// Aa?ii
				}// Aa?ii
				ll ans = -big;
				for(auto u : bruh)
					ans = max(ans, u.f * x[j].s.f + u.s);
				if(convex.size() > 0){
					ans = max(convex[0].f * x[j].s.f + convex[0].s, ans);
					ll l = 1, r = convex.size() - 1;
					while(l <= r) {
						ll m = (l + r) / 2;
						ld con = cross(convex[m - 1], convex[m]);
						if(con <= x[j].s.f)
							l = m + 1, ans = max(convex[m].f * x[j].s.f + convex[m].s, ans);
						else
							r = m - 1;
					}
				}
				cout << ans << '\n';
			}
		}
	}

}

/*
x
*/


#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll,pill>
#define ld long double

using namespace std;

const ll N = 1;
const ll big = 1e18;
const ll block = 800;
const ll mod = 1e6;

ll n;

set<pill> a;

vector<triple> x;

multiset<pill> cht;

ld cross(pill a,pill b){
	if(a.f == b.f)
		return big;
	return ((b.s - a.s) / (b.f - a.f));
}

int main() {
    speed;
    cin >> n;	// Âåðíî
    rep(0, n, 1) {// Âåðíî
    	ll t, a, b = 0;// Âåðíî
    	cin >> t >> a;// Âåðíî
    	if(t == 1) // Âåðíî
    		cin >> b;// Âåðíî
		x.pb({t, {a, b}});// Âåðíî
	}
	ll blocks = 1;// Âåðíî

	for(int i = 0; i < n; i += block) {// Âåðíî
		if( n == 5000 && i >= 100){
			cout << "daun\n";
			ex;
		}
		ll y = i;// Âåðíî
		multiset<pill> bruh;// Âåðíî
		ll r = min(n, y + block);// Âåðíî
		for(int j = y; j < r; j++) {// Âåðíî
			if(x[j].f == 2){// Âåðíî
				ll hm = x[j].s.f - 1;// Âåðíî
				pill amir = x[hm].s;// Âåðíî
				if(hm < y){// Âåðíî
					bruh.insert(amir);// Âåðíî
					auto it = cht.find(amir);// Âåðíî
					cht.erase(it);// Âåðíî
				}// Âåðíî
			}// Âåðíî
		}// Âåðíî
		// Íåèçâåñòíî
		vector<pill> convex;
		for(auto u : cht) {
			while(convex.size() > 1 && cross(convex[convex.size() - 2],u) >= cross(convex.back(), u))
				convex.pop_back();
			convex.pb(u);
		}
		// Íåèçâåñòíî
		for(int j = y; j < r; j++) {
			if(x[j].f == 1){
				bruh.insert(x[j].s);// Âåðíî
				cht.insert(x[j].s);// Âåðíî
			}
			if(x[j].f == 2){
				ll hm = x[j].s.f - 1;// Âåðíî
				pill amir = x[hm].s;// Âåðíî
				auto it = bruh.find(amir);// Âåðíî
				bruh.erase(it);// Âåðíî
				it = cht.find(amir);// Âåðíî
				cht.erase(it);// Âåðíî
			}
			if(x[j].f == 3) {
				if(bruh.size() == 0 && convex.size() == 0){// Âåðíî
					cout << "EMPTY SET\n";// Âåðíî
					continue;// Âåðíî
				}// Âåðíî
				ll ans = -big;
				for(auto u : bruh) {// Âåðíî
					ans = max(u.f * x[j].s.f + u.s, ans);// Âåðíî
				}// Âåðíî
				if(convex.size() > 0){
					ans = max(convex[0].f * x[j].s.f + convex[0].s, ans);
					ll l = 1, r = convex.size() - 1;
					while(l <= r) {
						ll m = (l + r) / 2;
						ld con = cross(convex[m - 1], convex[m]);
						if(con <= x[j].s.f)
							l = m + 1, ans = max(convex[m].f * x[j].s.f + convex[m].s, ans);
						else
							r = m - 1;
					}
				}
				cout << ans << '\n';
			}
		}
	}

}

/*
x
*/


#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll,pill>
#define ld long double
#define F first
#define S second.first
#define T second.second

using namespace std;

const ll N = 1;
const ll big = 6e18;
ll block = 800;
const ll mod = 1e6;

ll n;

set<pill> a;

vector<triple> t;

set<triple> cht;

vector<pill> convex;

ld cross(pill a,pill b){
    return (b.s - a.s + 0.0) / (a.f - b.f + 0.0);
}

void add(pill a) {
	ll z = x.size() - 1;;
	while(x.size() >= 2 && cross(x[z - 1], a) >= cross(x[z], x[z - 1]))
		x.pop_back(), z--;
	x.push_back({a});
}

int main() {
    speed;
    cin >> n;
    t.pb({0, {0, 0}});
    rep(0, n, 1) {
    	ll x, a, b = 0;
    	cin >> x >> a;
    	if(x == 1)
    		cin >> b;
		t.pb({x, {a, b}});
	}
	block = 4950;

	for(int i = 1; i <= n; i += block) {
		ll l = i, r = min(i + block, n + 1);

		set<triple> sub;

		for(int j = l; j < r; j++) {
			if(t[j].F == 2 && t[j].S < l) {
				triple del = {t[t[j].S].S, {t[t[j].S].T, t[j].S}};
				auto it = cht.find(del);
				cht.erase(it);
				sub.insert(del);
			}
		}
		for(auto u : cht)
			add({u.F,u.S});
		for(int j = l; j < r; j++) {
			if(t[j].F == 1) {
				cht.insert({t[j].S, {t[j].T, j}});
				sub.insert({t[j].S, {t[j].T, j}});
			}
			if(t[j].F == 2) {
				ll L = t[j].S;
				triple del = {t[L].S, { t[L].T, L}};
				auto it = sub.find(del);
				sub.erase(it);
				if(L >= l) {
					it = cht.find(del);
					cht.erase(it);
				}
			}
			if(t[j].F == 3) {
				ll ans = -big;
				if(sub.size() == 0 && cht.size() == 0) {
					cout << "EMPTY SET\n";
					continue;
				}
				ll x = t[j].S;
				for(auto u : sub)
					ans = max(ans, u.F * x + u.S);
				if(convex.size() > 0) {
					ll L = 1, R = convex.size() - 1;
					ans = max(convex[0].f * x + convex[0].s, ans);
					ld XX = x;
					while(L <= R) {
						ll m = (L + R) >> 1;
						ans = max(convex[m].f * x + convex[m].s, ans);
						if(cross(convex[m], convex[m - 1]) > XX)
							R = m - 1;
						else
							L = m + 1;
					}
				}
				cout << ans << '\n';
			}
		}

		convex.clear();
	}

}

/*
x
*/


#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<ll,pill>
#define ld long double
#define F first
#define S second.first
#define T second.second

using namespace std;

const ll N = 1;
const ll big = 6e18;
ll block = 800;
const ll mod = 1e6;

ll n;

set<pill> a;

vector<triple> t;

set<triple> cht;

vector<pill> convex;

ld cross(pill a,pill b){
    return (b.s - a.s + 0.0) / (a.f - b.f + 0.0);
}

void add(pill a){
    ll szs = sz(convex);
    while(sz(convex) > 1){
        if(cross(a , convex[szs - 2]) > cross(convex[szs - 1] , convex[szs - 2]) )
            break;
        convex.pop_back();
        szs = sz(convex);
    }
    convex.pb(a);
}

int main() {
    speed;
    cin >> n;
    t.pb({0, {0, 0}});
    rep(0, n, 1) {
    	ll x, a, b = 0;
    	cin >> x >> a;
    	if(x == 1)
    		cin >> b;
		t.pb({x, {a, b}});
	}
	block = sqrt(n);

	for(int i = 1; i <= n; i += block) {
		ll l = i, r = min(i + block, n + 1);

		set<triple> sub;

		for(int j = l; j < r; j++) {
			if(t[j].F == 2 && t[j].S < l) {
				triple del = {t[t[j].S].S, {t[t[j].S].T, t[j].S}};
				auto it = cht.find(del);
				cht.erase(it);
				sub.insert(del);
			}
		}
		for(auto u : cht)
			add({u.F,u.S});
		for(int j = l; j < r; j++) {
			if(t[j].F == 1) {
				cht.insert({t[j].S, {t[j].T, j}});
				sub.insert({t[j].S, {t[j].T, j}});
			}
			if(t[j].F == 2) {
				ll L = t[j].S;
				triple del = {t[L].S, { t[L].T, L}};
				auto it = sub.find(del);
				sub.erase(it);
				if(L >= l) {
					it = cht.find(del);
					cht.erase(it);
				}
			}
			if(t[j].F == 3) {
				ll ans = -big;
				if(sub.size() == 0 && cht.size() == 0) {
					cout << "EMPTY SET\n";
					continue;
				}
				ll x = t[j].S;
				for(auto u : sub)
					ans = max(ans, u.F * x + u.S);
				if(convex.size() > 0) {
					ll L = 1, R = convex.size() - 1;
					ans = max(convex[0].f * x + convex[0].s, ans);
					ld XX = x;
					while(L <= R) {
						ll m = (L + R) >> 1;
						ans = max(convex[m].f * x + convex[m].s, ans);
						if(cross(convex[m], convex[m - 1]) > XX)
							R = m - 1;
						else
							L = m + 1;
					}
				}
				cout << ans << '\n';
			}
		}

		convex.clear();
	}

}

/*
x
*/