#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>

using namespace std;

const int maxN = 50005;

int n, q;
int a[maxN];

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]);

    int ctrl;
    int left, right, high, low;
    scanf("%d", &q);

    for (int i = 0; i < q; ++i) {
        scanf("%d", &ctrl);
        if ( ctrl == 1 ) {
            scanf("%d%d%d%d", &left, &right, &low, &high);
            int cnt = 0;
            for (int j = left; j <= right; ++j)
                if ( low <= a[j] && a[j] <= high )
                    cnt++;
            printf("%d\n", cnt);
        }
        else {
            int idx, newVal;
            scanf("%d%d", &idx, &newVal);
            a[idx] = newVal;
        }
    }

    //system("PAUSE");
    return 0;
}
