#include <cstdio>
#include <cstdlib>
#define MAXN 50000
using namespace std;
typedef long long lld;
lld niz[MAXN];
int n,q,upit,l,r,a,b;
lld rez = 0;
int i,j,k;
int main(){
    freopen("pijaca.in","r",stdin);
    freopen("pijaca.out","w",stdout);
    scanf("%lld",&n);
    for(i=1;i<=n;++i) scanf("%lld",&niz[i]);
    scanf("%lld",&q);
    for( j=0;j<q;++j){
            scanf("%lld %lld %lld",&upit,&l,&r);
            if(upit==1){ 
                         scanf("%lld %lld",&a,&b);
                         rez = 0;
                             for(k = l;k<=r;++k)
                                     if(niz[k]>=a&&niz[k]<=b) rez++;
                        printf("%lld\n",rez);
                        }
            else {
                 niz[l] = r;
                 }
    }
    return 0;
}
