You've got an array *a*, consisting of *n* integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub>. You are allowed to perform two operations on this array:
 1.  Calculate the sum of current array elements on the segment [*l*, *r*], that is, count value *a*<sub class="lower-index">*l*</sub> + *a*<sub class="lower-index">*l* + 1</sub> + ... + *a*<sub class="lower-index">*r*</sub>. 1.  Apply the xor operation with a given number *x* to each array element on the segment [*l*, *r*], that is, execute <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/2ef04d094daf2dcff9a998a558bd9cab93bbd012.png" style="max-width: 100.0%;max-height: 100.0%;"/>. This operation changes exactly *r* - *l* + 1 array elements. 
Expression <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/b364f2e04c665b78b924ec10666327a4ef4635bc.png" style="max-width: 100.0%;max-height: 100.0%;"/> means applying bitwise xor operation to numbers *x* and *y*. The given operation exists in all modern programming languages, for example in language C++ and Java it is marked as "^", in Pascal — as "xor".

You've got a list of *m* operations of the indicated type. Your task is to perform all given operations, for each sum query you should print the result you get.
The first line contains integer *n* (1 ≤ *n* ≤ 10<sup class="upper-index">5</sup>) — the size of the array. The second line contains space-separated integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (0 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">6</sup>) — the original array.

The third line contains integer *m* (1 ≤ *m* ≤ 5·10<sup class="upper-index">4</sup>) — the number of operations with the array. The *i*-th of the following *m* lines first contains an integer *t*<sub class="lower-index">*i*</sub> (1 ≤ *t*<sub class="lower-index">*i*</sub> ≤ 2) — the type of the *i*-th query. If *t*<sub class="lower-index">*i*</sub> = 1, then this is the query of the sum, if *t*<sub class="lower-index">*i*</sub> = 2, then this is the query to change array elements. If the *i*-th operation is of type 1, then next follow two integers *l*<sub class="lower-index">*i*</sub>, *r*<sub class="lower-index">*i*</sub> (1 ≤ *l*<sub class="lower-index">*i*</sub> ≤ *r*<sub class="lower-index">*i*</sub> ≤ *n*). If the *i*-th operation is of type 2, then next follow three integers *l*<sub class="lower-index">*i*</sub>, *r*<sub class="lower-index">*i*</sub>, *x*<sub class="lower-index">*i*</sub> (1 ≤ *l*<sub class="lower-index">*i*</sub> ≤ *r*<sub class="lower-index">*i*</sub> ≤ *n*, 1 ≤ *x*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">6</sup>). The numbers on the lines are separated by single spaces.
# Author Name: Ajay Meena
# Codeforce : https://codeforces.com/profile/majay1638
import sys
import math
import bisect
import heapq
from bisect import bisect_right
from sys import stdin, stdout

# -------------- INPUT FUNCTIONS ------------------


def get_ints_in_variables(): return map(
    int, sys.stdin.readline().strip().split())


def get_int(): return int(sys.stdin.readline())


def get_ints_in_list(): return list(
    map(int, sys.stdin.readline().strip().split()))
def get_list_of_list(n): return [list(
    map(int, sys.stdin.readline().strip().split())) for _ in range(n)]


def get_string(): return sys.stdin.readline().strip()

# -------- SOME CUSTOMIZED FUNCTIONS-----------


def myceil(x, y): return (x + y - 1) // y

# -------------- SOLUTION FUNCTION ------------------
class LazySegmentTree:
    def __init__(self, n):
        self.base = 1
        while self.base < n:
            self.base *= 2
        self.tree = [0] * (self.base * 2)
        self.lazy = [0] * (self.base * 2)

    def _flush(self, pos, l, r):
        if self.lazy[pos] != 0:
            assert self.lazy[pos] == 1
            self.tree[pos] = r - l + 1 - self.tree[pos]
            if pos < self.base:
                self.lazy[2 * pos] ^= self.lazy[pos]
                self.lazy[2 * pos + 1] ^= self.lazy[pos]
            self.lazy[pos] = 0

    def _get_sum(self, l, r, nl, nr, pos):
        self._flush(pos, nl, nr)
        if max(l, nl) > min(r, nr):
            return 0
        if l <= nl and nr <= r:
            return self.tree[pos]
        mid = (nl + nr) // 2
        return self._get_sum(l, r, nl, mid, 2 * pos) + self._get_sum(l, r, mid + 1, nr, 2 * pos + 1)

    def get_sum(self, l, r):
        return self._get_sum(l, r, 0, self.base - 1, 1)

    def _flip(self, l, r, nl, nr, pos):
        self._flush(pos, nl, nr)
        if max(l, nl) > min(r, nr):
            return
        if l <= nl and nr <= r:
            self.lazy[pos] = 1
            self._flush(pos, nl, nr)
            return
        mid = (nl + nr) // 2
        self._flip(l, r, nl, mid, 2 * pos)
        self._flip(l, r, mid + 1, nr, 2 * pos + 1)
        self.tree[pos] = self.tree[2 * pos] + self.tree[2 * pos + 1]

    def flip(self, l, r):
        self._flip(l, r, 0, self.base - 1, 1)

def Solution():
    # Write Your Code Here
    K = 20
    n = int(input())
    arrays = [LazySegmentTree(n) for _ in range(K)]
    for i, x in enumerate(map(int, input().split())):
        for j in range(K):
            if x & (1 << j):
                arrays[j].flip(i, i)
    m = int(input())
    res = []
    for _ in range(m):
        t = tuple(map(int, input().split()))
        l, r = t[1] - 1, t[2] - 1
        if t[0] == 1:
            cur = 0
            for i in range(K):
                cur += arrays[i].get_sum(l, r) << i
            res.append(cur)
        else:
            assert t[0] == 2
            x = t[3]
            for i in range(K):
                if x & (1 << i):
                    arrays[i].flip(l, r)
    print("\n".join(map(str, res)))




def main():
    # Take input Here and Call solution function
    Solution()


# calling main Function
if __name__ == '__main__':
    main()
