#include "stdio.h"
#include "stdlib.h"
//drugi zad.
int *x;

int funk(int l,int r, int a, int b){
    int i,s=0;
    for(i=l;i<=r;i++) if((x[i]<=b)&&(x[i]>=a)) s++;
    return s;   
}

int main(){
FILE *in=fopen("pijaca.in","r"),*out=fopen("pijaca.out","w");
     
     int n,t,p,a,b,l,r,i;
     fscanf(in,"%d",&n);
     x=(int*)malloc(n*sizeof(int));
     for(i=0;i<n;i++) fscanf(in,"%d",x+i);
     fscanf(in,"%d",&t);
     while(t--){
                fscanf(in,"%d",&p);
                if (p==2) {
                         fscanf(in,"%d %d",&a,&b);
                                  x[a-1]=b;
                }
                else {
                     fscanf(in,"%d %d %d %d",&l,&r,&a,&b);
                     fprintf(out,"%d\n",funk(l-1,r-1,a,b));
                }
     }
    
fclose(in);fclose(out);return 0;
}
