#include <bits/stdc++.h>
using namespace std;
int n, m, l, r, x, t;
int a[100001];
int main() {
  scanf("%d", &n);
  for (int(i) = (1); i < (n + 1); ++(i)) scanf("%d", &a[i]);
  scanf("%d", &m);
  for (int(ttt) = (0); ttt < (m); ++(ttt)) {
    scanf("%d%d%d", &t, &l, &r);
    if (t == 1) {
      long long res = 0;
      int q = 0;
      for (int i = l, k = 1; i <= r; i++, k++) {
        q += a[i];
        if (k == 2500) {
          res += q;
          k = 1;
          q = 0;
        }
      }
      res += q;
      cout << res << '\n';
    } else {
      scanf("%d", &x);
      for (int i = l; i <= r; ++i) a[i] ^= x;
    }
  }
  return 0;
}
