#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 123;
int n;
ll a[N];
vector <ll> basis;

void add(ll x) {
	for (ll i : basis) {
		x = min(x, x ^ i);
	}
	if (x > 0) {
		basis.pb(x);
	}
}

int f(ll x) {
	for (int i = 59; i >= 0; i--) {
		if (x >> i & 1) {
			return i;
		}
	}
	return -1;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n;
	ll t = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		t ^= a[i];
	}
	ll ans = t, rt = t ^ ((1ll << 60) - 1);
	for (int i = 1; i <= n; i++) {
		a[i] &= rt;
		add(a[i]);
	}
	sort(all(basis));
	reverse(all(basis));
	ll res = 0;
	for (ll i : basis) {
		if (res >> f(i) & 1) {
			continue;
		}
		res ^= i;
	}
	ans += 2 * res;
	cout << ans;
}

//hail to jwalaji
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define mod 1000000007
int main(){
    //ios::sync_with_stdio(false);
    //cin.tie(NULL);
//lli t;
//cin>>t;
//while(t--){
    lli n;
    cin>>n;
    vector<lli> arr(n),store(n);
    for(lli i=0;i<n;i++){
        cin>>arr[i];
    }
    store[0]=arr[0]%mod;
    for(lli i=1;i<n;i++){
        store[i]=(arr[i]+store[i-1])%mod;
    }
    lli ans=0;
    for(lli i=1;i<n;i++){
        ans=(ans+store[i-1]*arr[i])%mod;
    }
    cout<<ans<<endl;
//}
return 0;
}
