#include using namespace std; int main(){ int N; cin >> N; vector A(N); for (int i = 0; i < N; i++){ cin >> A[i]; } vector B(N); for (int i = 0; i < N; i++){ cin >> B[i]; } vector S(N + 1); S[0] = 0; for (int i = 0; i < N; i++){ S[i + 1] = S[i] ^ B[i]; } vector> C(2, vector(N + 1)); C[0][0] = 0; C[1][0] = 0; for (int i = 0; i < N; i++){ C[0][i + 1] = C[0][i]; C[1][i + 1] = C[1][i]; C[S[i + 1]][i + 1]++; } long long ans = 0; vector R(30, N); int r = N; for (int i = N - 1; i >= 0; i--){ for (int j = 0; j < 30; j++){ if ((A[i] >> j & 1) == 1){ r = min(r, R[j]); R[j] = i; } } ans += C[S[i]][r] - C[S[i]][i]; } cout << ans << endl; }