#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <cmath>
#include <vector>
#include <fstream>


using namespace std;

int n,i,Q; int a[50005];



int main()
{
    FILE *fin, *fout;
    fin = fopen("pijaca.in", "r");
    fout = fopen("pijaca.out", "w");
    fscanf(fin,"%d", &n);
    for (i = 0; i < n; i++) fscanf(fin,"%d", &a[i]);
    fscanf(fin,"%d",&Q);
    int x,i1,i2,A,B;
    /*for (i = 0; i < n; i++) printf("%d ", a[i]);
    printf("\n");*/
    for (i = 0; i < Q; i++)
    {
        fscanf(fin,"%d",&x);
       
        if ( x == 1)
        {
             fscanf(fin,"%d%d%d%d", &i1, &i2, &A, &B);
             int sum = 0;
             for (int j = i1-1; j <= i2-1; j++)
             {
                // printf("----- %d ", a[j]);
                 if (a[j] >= A && a[j] <= B) sum++;
             }
             fprintf(fout,"%d\n", sum);
        } 
        else
        {
            fscanf(fin,"%d%d", &A, &B);
            a[A-1] = B;
        }
    }
    
    //system("pause");
    fclose(fin);
    fclose(fout);
    return 0;
    
    
}
