#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 main(){
    freopen("pijaca.in","r",stdin);
    freopen("pijaca.out","w",stdout);
    scanf("%I64d",&n);
    for(int i=1;i<=n;++i) scanf("%lld",&niz[i]);
    scanf("%I64d",&q);
    for(int j=0;j<q;++j){
            scanf("%I64d %I64d %I64d",&upit,&l,&r);
            if(upit==1){ 
                         scanf("%I64d %I64d",&a,&b);
                         rez = 0;
                             for(int k = l;k<=r;++k)
                                     if(niz[k]>=a&&niz[k]<=b) rez++;
                        printf("%I64d\n",rez);
                        }
            else {
                 niz[l] = r;
                 }
    }
    return 0;
}
