#include <stdio.h>

using namespace std;

int main()
{
    freopen("pijaca.in", "r", stdin );
    freopen("pijaca.out", "w", stdout );

    int n;
    scanf("%d", &n );

    int v[ n + 5 ];

    for ( int i = 1; i <= n; i ++ ) scanf("%d", &v[ i ] );

    int m;
    scanf("%d", &m );

    while ( m -- )
    {
        int k;
        scanf("%d", &k );

        if ( k == 1 )
        {
            int l, r, a, b;
            scanf("%d%d%d%d", &l, &r, &a, &b );

            int res = 0;

            for ( int i = l; i <= r; i ++ )

                if ( v[ i ] >= a && v[ i ] <= b ) res ++;

            printf("%d\n", res );
        }
        else
        {
            int poz, vred;
            scanf("%d%d", &poz, &vred );

            v[ poz ] = vred;
        }
    }

    return 0;
}
