#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long mod = pow(10, 9) + 7;
  vector<unsigned long> a(n);
  unsigned long maxA = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    maxA = max(a[i], maxA);
  }
  if (false) {
    long long ans = 0;
    vector<vector<int>> vv(n);
    for (int i = 0; i < n - 1; i++) {
      vv[i] = vector<int>(n, 0);
      for (int j = i + 1; j < n; j++) {
        vv[i][j]++;
        ans += a[i] ^ a[j];
        ans %= mod;
      }
    }
    cout << ans << endl;
  }
  if (n == 2) {
    cout << (a[0] ^ a[1]) << endl;
    return 0;
  }
  vector<vector<int>> bitnum;
  for (int i = 0; i < 62; i++) {
    unsigned long long mask = (unsigned long long)0x01 << (unsigned long long)i;
    if (mask > maxA) break;
    bitnum.push_back(vector<int>(n, 0));
    for (int j = 0; j < n; j++) {
      if ((a[j] & mask) == mask) {
        if (j == 0) {
          bitnum[i][j] = 1;
        } else {
          bitnum[i][j] = bitnum[i][j - 1] + 1;
        }
      } else {
        if (j == 0) {
          bitnum[i][j] = 0;
        } else {
          bitnum[i][j] = bitnum[i][j - 1];
        }
      }
    }
  }
  vector<int> xorSum(bitnum.size(), 0);
  for (int i = 0; i < bitnum.size(); i++) {
    for (int j = 0; j < n - 1; j++) {
      int num = bitnum[i][n - 1];
      num -= bitnum[i][j];
      int currentBit;
      if (j == 0) {
        currentBit = bitnum[i][j];
      } else {
        currentBit = bitnum[i][j] - bitnum[i][j - 1];
      }
      if (currentBit == 0) {
        xorSum[i] += num;
      } else {
        int maxNum = n - (j + 1);
        xorSum[i] += (maxNum - num);
      }
    }
  }
  unsigned long long ans = 0;
  for (int i = 0; i < xorSum.size(); i++) {
    if (xorSum[i] == 0) continue;
    int exp = i;
    unsigned long long tmp = xorSum[i];
    while (exp > 0) {
      tmp *= 2;
      tmp %= mod;
      exp--;
    }
    ans += tmp;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}
