#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5;
const long long INF = 1e18L;
long long ar[N];
long long dp[N];
inline long long add(long long x, long long y, long long mod) {
  if (x >= mod) x %= mod;
  if (y >= mod) y %= mod;
  x += y;
  return (x >= mod ? x - mod : x);
}
inline long long mul(long long x, long long y, long long mod) {
  if (x >= mod) x %= mod;
  if (y >= mod) y %= mod;
  return (x * y) % mod;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long T = 1;
  long long mod = 1000000007;
  while (T--) {
    long long n;
    cin >> n;
    map<long long, long long> mp;
    for (long long i = 0; i < n; i++) {
      cin >> ar[i];
      mp[ar[i]]++;
    }
    long long ans = 0;
    for (long long i = 0; i < n; i++) {
      mp[ar[i]]--;
      for (auto it : mp) {
        long long x = 0;
        x = add(x, ar[i] ^ it.first, mod);
        x %= mod;
        x = mul(x, it.second, mod);
        ans = add(ans, x, mod);
      }
    }
    cout << ans << endl;
  }
  cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
  return 0;
}
