/*
███████ ██████ ███ ██ ██ ██████ ██ ██ ██ ██ ██ ██
██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██
███████ ██ ██ ██ ██ ██ ██ ██ ███████ ███████ ███████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
███████ ██████ ██ ████ ██ ██████ ██ ██ ██
*/
#include <bits/stdc++.h>
using namespace std;
#define sonic ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define ll long long
#define gcd __gcd
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define acc(x) accumulate(all(x),0LL)
#define fixed(n) fixed << setprecision(n)
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define mx(v) *max_element(all(v))
#define mn(v) *min_element(all(v))
#define mxi(v) max_element(all(v))-v.begin()
#define mni(v) min_element(all(v))-v.begin()
#define cin(vec) for(auto &i : vec) cin >> i
#define cout(vec) for(auto& i : vec) cout << i << " "; cout << '\n';
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
class Sqrtdeco {
ll n, ign = 0, SQ = 450;// 318 for 1e5, 450 for 2e5
vector<ll> arr, block, sum;
vector<vector<ll>>blks;
public:
Sqrtdeco(vector<ll> &v) {
arr = v;
sum = vector<ll>(SQ, 0);
block = vector<ll>(SQ, ign);
vector<ll> q;
for (int i = 0; i < v.size(); ++i) {
if (i != 0 && i % SQ == 0) {
blks.emplace_back(q);
q.clear();
q.emplace_back(arr[i]);
} else q.emplace_back(arr[i]);
}
if (q.size())blks.emplace_back(q);
}
void set(ll i, ll v) {
ll l = i - i % SQ, r = l + SQ - 1;
arr[i] = v;
vector<ll> w;
for (int j = l; j < min<ll>(r,arr.size()); ++j) {
w.emplace_back(arr[j]);
}
sort(all(w));
blks[i / SQ] = w;
}
ll qry(ll le, ll rr, ll v) {
// ll l = i - i % SQ, r = l + SQ - 1;
ll res=0;
while (le <= rr) {
if (le % SQ == 0 && le + SQ - 1 <= rr) {
vector<ll> vv = blks[le / SQ];
res += vv.size() - (lower_bound(all(vv), v) - vv.begin());
le += SQ;
} else {
if (arr[le] >= v)res++;
le++;
}
}
return res;
}
};
void sonic444() {
ll n;cin>>n;
vector<ll>v(n);
cin(v);
ll q; cin>>q;
Sqrtdeco sq(v);
for (int i = 0; i < q; ++i) {
ll a;cin>>a;
if(a==0){
ll l,r,c;cin>>l>>r>>c;
l--,r--;
cout<<sq.qry(l,r,c)<<endl;
}
else{
ll i,c;cin>>i>>c;
i--;
sq.set(i,c);
}
}
}
int main() {
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
sonic
//////////////////////////////////////////////
int t = 1;
// cin>>t;
while (t--) {
sonic444();
}
return 0;
}
LyoK4paI4paI4paI4paI4paI4paI4paIICDilojilojilojilojilojiloggIOKWiOKWiOKWiCAgICDilojilogg4paI4paIICDilojilojilojilojilojilogg4paI4paIICAg4paI4paIIOKWiOKWiCAgIOKWiOKWiCDilojiloggICDilojilogK4paI4paIICAgICAg4paI4paIICAgIOKWiOKWiCDilojilojilojiloggICDilojilogg4paI4paIIOKWiOKWiCAgICAgIOKWiOKWiCAgIOKWiOKWiCDilojiloggICDilojilogg4paI4paIICAg4paI4paICuKWiOKWiOKWiOKWiOKWiOKWiOKWiCDilojiloggICAg4paI4paIIOKWiOKWiCDilojiloggIOKWiOKWiCDilojilogg4paI4paIICAgICAg4paI4paI4paI4paI4paI4paI4paIIOKWiOKWiOKWiOKWiOKWiOKWiOKWiCDilojilojilojilojilojilojilogKICAgICDilojilogg4paI4paIICAgIOKWiOKWiCDilojiloggIOKWiOKWiCDilojilogg4paI4paIIOKWiOKWiCAgICAgICAgICAg4paI4paIICAgICAg4paI4paIICAgICAg4paI4paICuKWiOKWiOKWiOKWiOKWiOKWiOKWiCAg4paI4paI4paI4paI4paI4paIICDilojiloggICDilojilojilojilogg4paI4paIICDilojilojilojilojilojiloggICAgICDilojiloggICAgICDilojiloggICAgICDilojilogKKi8KI2luY2x1ZGUgPGJpdHMvc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dmVjdG9yPGxsPj5ibGtzOwpwdWJsaWM6CiAgICBTcXJ0ZGVjbyh2ZWN0b3I8bGw+ICZ2KSB7CiAgICAgICAgYXJyID0gdjsKICAgICAgICBzdW0gPSB2ZWN0b3I8bGw+KFNRLCAwKTsKICAgICAgICBibG9jayA9IHZlY3RvcjxsbD4oU1EsIGlnbik7CiAgICAgICAgdmVjdG9yPGxsPiBxOwogICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgdi5zaXplKCk7ICsraSkgewogICAgICAgICAgICBpZiAoaSAhPSAwICYmIGkgJSBTUSA9PSAwKSB7CiAgICAgICAgICAgICAgICBibGtzLmVtcGxhY2VfYmFjayhxKTsKICAgICAgICAgICAgICAgIHEuY2xlYXIoKTsKICAgICAgICAgICAgICAgIHEuZW1wbGFjZV9iYWNrKGFycltpXSk7CiAgICAgICAgICAgIH0gZWxzZSBxLmVtcGxhY2VfYmFjayhhcnJbaV0pOwogICAgICAgIH0KICAgICAgICBpZiAocS5zaXplKCkpYmxrcy5lbXBsYWNlX2JhY2socSk7CiAgICB9CgoKICAgIHZvaWQgc2V0KGxsIGksIGxsIHYpIHsKICAgICAgICBsbCBsID0gaSAtIGkgJSBTUSwgciA9IGwgKyBTUSAtIDE7CiAgICAgICAgYXJyW2ldID0gdjsKICAgICAgICB2ZWN0b3I8bGw+IHc7CiAgICAgICAgZm9yIChpbnQgaiA9IGw7IGogPCBtaW48bGw+KHIsYXJyLnNpemUoKSk7ICsraikgewogICAgICAgICAgICB3LmVtcGxhY2VfYmFjayhhcnJbal0pOwogICAgICAgIH0KICAgICAgICBzb3J0KGFsbCh3KSk7CiAgICAgICAgYmxrc1tpIC8gU1FdID0gdzsKCgogICAgfQoKICAgIGxsIHFyeShsbCBsZSwgbGwgcnIsIGxsIHYpIHsKICAgICAgICAvLyAgIGxsIGwgPSBpIC0gaSAlIFNRLCByID0gbCArIFNRIC0gMTsKICAgICAgICAgbGwgcmVzPTA7CiAgICAgICAgd2hpbGUgKGxlIDw9IHJyKSB7CiAgICAgICAgICAgIGlmIChsZSAlIFNRID09IDAgJiYgbGUgKyBTUSAtIDEgPD0gcnIpIHsKICAgICAgICAgICAgICAgIHZlY3RvcjxsbD4gdnYgPSBibGtzW2xlIC8gU1FdOwogICAgICAgICAgICAgICAgcmVzICs9IHZ2LnNpemUoKSAtIChsb3dlcl9ib3VuZChhbGwodnYpLCB2KSAtIHZ2LmJlZ2luKCkpOwogICAgICAgICAgICAgICAgbGUgKz0gU1E7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICBpZiAoYXJyW2xlXSA+PSB2KXJlcysrOwogICAgICAgICAgICAgICAgbGUrKzsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gcmVzOwogICAgfQoKCn07CgoKdm9pZCBzb25pYzQ0NCgpIHsKCiAgbGwgbjtjaW4+Pm47CiAgdmVjdG9yPGxsPnYobik7CiAgICBjaW4odik7CiAgICBsbCBxOyBjaW4+PnE7CiAgICBTcXJ0ZGVjbyBzcSh2KTsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgcTsgKytpKSB7CiAgICAgICAgbGwgYTtjaW4+PmE7CiAgICAgICAgaWYoYT09MCl7CiAgICAgICAgICAgIGxsIGwscixjO2Npbj4+bD4+cj4+YzsKICAgICAgICAgICAgbC0tLHItLTsKICAgICAgICAgICAgY291dDw8c3EucXJ5KGwscixjKTw8ZW5kbDsKICAgICAgICB9CiAgICAgICAgZWxzZXsKICAgICAgICAgICBsbCBpLGM7Y2luPj5pPj5jOwogICAgICAgICAgIGktLTsKICAgICAgICAgIHNxLnNldChpLGMpOwogICAgICAgIH0KICAgIH0KCgoKfQoKaW50IG1haW4oKSB7CiAgICAvLyAgICBmcmVvcGVuKCJpbnB1dC50eHQiLCAiciIsIHN0ZGluKTsKICAgIC8vICAgIGZyZW9wZW4oIm91dHB1dC50eHQiLCAidyIsIHN0ZG91dCk7CiAgICBzb25pYwogICAgLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLwogICAgaW50IHQgPSAxOwogICAgLy8gY2luPj50OwoKICAgIHdoaWxlICh0LS0pIHsKCiAgICAgICAgc29uaWM0NDQoKTsKCiAgICB9CiAgICByZXR1cm4gMDsKfQo=