#include <bits/stdc++.h>
#define MAXN 100010
#define BR 100

using namespace std;

typedef  long long ll;

ll a[MAXN];
ll br[BR];
ll n;

void napravi()
{
    for(int i = 1; i <= n; i++)
    {
        ll A = a[i];
        ll j = 0;
        while(A > 0)
        {
            br[j] += A % 2;
            A /= 2;
            j++;
        }
    }
}

void smanji(ll m)
{
    ll j = 0;
    while(m > 0)
    {
        br[j] -= m % 2;
        m /= 2;
        j++;
    }
}

void povecaj(ll m)
{
    ll j = 0;
    while(m > 0)
    {
        br[j] -= m % 2;
        m /= 2;
        j++;
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    napravi();
    ll q; cin >> q;
    ll t, k, x;
    while(q--)
    {
        cin >> t >> k;
        if(t == 0)
        {
            ll rez = 0;
            ll dvana = 1;
            for(int i = 0; i <= 40; i++)
            {
                if(k <= br[i]) rez += dvana;
                dvana *= 2;
            }
            cout << rez << "\n";
        }
        else
        {
            cin >> x;
            smanji(a[k]);
            a[k] = x;
            povecaj(a[k]);
        }
    }
    return 0;
}