#include<iostream>
#include<stdio.h>
#include<queue>
#include<deque>
#include<stdlib.h>
#include<algorithm>
#include<utility>
#include<stack>
#include<set>
#include<cstring>
#include<vector>
using namespace std;


int n,q;
int a[60000];


int main()
{
    freopen("pijaca.in","r",stdin);
    freopen("pijaca.out","w",stdout);
    scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    scanf("%d",&q);
    while (q--)
    {
      int COM=0;
      int I,J,x,y;
      int SOL=0;
      scanf("%d",&COM);
      if (COM==1) 
      {
                  scanf("%d %d %d %d",&I,&J,&x,&y);
                  for (int i=I;i<=J;i++) if ((a[i]>=x) && (a[i]<=y)) SOL++;
                  printf("%d\n",SOL);
      }
       if (COM==2)
       {
                  scanf("%d %d",&I,&x);
                  a[I]=x;
       }   
    }
    
    return 0;
}
