//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    vector<lint> zero(60);
    vector<lint> one(60);
    
    int n;cin>>n;
    lint x,tmp,ans=0;
    for(int i=0;i<n;i++){
        cin>>x;
        for(int j=0;j<60;j++){
            tmp=x%2;
            if(tmp==0)zero[j]++;
            else one[j]++;
            x/=2;
        }
    }
    const int mod=1000000007;
    tmp=1;
    for(int i=0;i<60;i++){
        ans+=(zero[i]*one[i]%mod)*tmp;
        ans%=mod;
        tmp=tmp*2%mod;
    }
    cout<<ans<<endl;
}

#include <bits/stdc++.h>

using namespace std; 

const int maxn = 1e5; 

int n, a[4][maxn + 5], p[maxn + 5], num[2]; 

int main() {
    scanf("%d", &n); 
    for (int i = 1; i <= 3; i++) {
        for (int j = 1; j <= n; j++) {
            scanf("%d", &a[i][j]); 
            if (i == 2) {
                p[j] = (a[i][j] + 1) / 3;
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        if (abs(a[1][i] - a[3][i]) != 2 || abs(a[1][i] - a[2][i]) != 1 || abs(a[2][i] - a[3][i]) != 1) {
            puts("No"); 
            return 0; 
        }
        if (p[i] % 2 != i % 2) {
            puts("No");
            return 0; 
        }
        int mn = min(a[1][i], a[3][i]), mx = max(a[1][i], a[3][i]); 

        if (mx % 3 != 0 || mn % 3 != 1) {
            puts("No");
            return 0; 
        }
        if (a[1][i] % 3 == 0) {
            num[i & 1]++; 
        }
    }
    for (int i = 1; i <= n; i++) {
        while (p[i] != i) {
            num[!(i & 1)]++; swap(p[i], p[p[i]]); 
        }   
    }
    if ((num[0] & 1) or (num[1] & 1)) puts("No");  
    else puts("Yes"); 
    return 0; 
}