/*
Petar 'PetarV' Velickovic
Task: Pijaca - Brute Force Approach
*/

#include <stdio.h>
#define MAX_N 1000001

int n,q;
int niz[MAX_N];
int kom,L,R,A,B,x;

int main()
{
    freopen("pijaca.in","r",stdin);
    freopen("pijaca.out","w",stdout);
    scanf("%d",&n);
    for (int i=0;i<n;i++)
    {
        scanf("%d",&niz[i]);
    }
    scanf("%d",&q);
    for (int i=0;i<q;i++)
    {
        scanf("%d",&kom);
        if (kom==1)
        {
          scanf("%d%d%d%d",&L,&R,&A,&B);
          L--; R--;
          int sol=0;
          for (int i=L;i<=R;i++)
          {
              if (niz[i]>=A && niz[i]<=B) sol++;
          }          
          printf("%d\n",sol);
        }
        else if (kom==2)
        {
          scanf("%d%d",&L,&x);
          niz[--L]=x;
        }
    }         
    return 0;
}
