#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
int n, m;
int a[1000000];
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  cin >> m;
  while (m--) {
    int t, l, r;
    cin >> t >> l >> r;
    if (t == 1) {
      long long int s = 0;
      for (int i = l; i <= r; i++) s += a[i];
      cout << s << "\n";
    } else {
      int x;
      cin >> x;
      for (int i = l; i <= r; i++) a[i] ^= x;
    }
  }
  return 0;
}
