#include "happiness.h"
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(), x.end()
#define IMAX INT_MAX
#define IMIN INT_MIN
#define LMAX LLONG_MAX
#define LMIN LLONG_MIN
#define MOD 1000000007
#define SIR 1000000009
multiset<ll> coins;
bool check() {
int sum = 0;
for (auto &x : coins) {
if (x > sum + 1) return false;
sum += x;
}
return true;
}
bool init(int n, long long M, long long init[]) {
for (int i = 0; i < n; i++) {
coins.insert(init[i]);
}
return check();
}
bool is_happy(int event, int n, long long dif[]) {
for (int i = 0; i < n; i++) {
if (event == 1) coins.insert(dif[i]);
else coins.erase(coins.find(dif[i]));
}
return check();
}