#include <bits/stdc++.h>
using namespace std;
long long int f1(long long int l, long long int r, long long int n,
                 long long int a[]) {
  long long int mod = (1e9) + 7;
  if (l == r)
    return a[l] ^ n;
  else {
    long long int m = (l + r) / 2;
    long long int t1 = f1(l, m, n, a) % mod;
    long long int t2 = f1(m + 1, r, n, a) % mod;
    return (t1 + t2) % mod;
  }
}
int32_t main() {
  long long int n;
  cin >> n;
  long long int a[n];
  long long int mod = (1e9) + 7;
  for (long long int i = 0; i < n; i++) cin >> a[i];
  long long int sum = 0;
  for (long long int i = 0; i < n; i++) {
    sum = (sum + f1(i, n - 1, a[i], a)) % mod;
  }
  cout << sum << endl;
  return 0;
}
