#include <bits/stdc++.h>
using namespace std;
vector<long> read();
long long naiveThink(const vector<long> &);
long long think(const vector<long> &);
void write(long long);
int numOfBits(long);
bool isBitSet(long, int);
int main(int argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  auto input = read();
  auto output = think(input);
  write(output);
  return 0;
}
vector<long> read() {
  int n;
  long buf;
  scanf("%d", &n);
  auto input = vector<long>(n);
  for (int i = 0; i < n; i++) {
    scanf("%ld", &buf);
    input.at(i) = buf;
  }
  return input;
}
long long naiveThink(const vector<long> &input) {
  long mode = 1000000000 + 7;
  long long result = 0;
  for (int i = 0; i < input.size(); i++) {
    for (int j = i + 1; j < input.size(); j++) {
      result += input.at(i) ^ input.at(j);
      result %= mode;
    }
  }
  return result;
}
long long think(const vector<long> &input) {
  long long mode = 1000000000 + 7;
  long long result = 0;
  auto max = *max_element(input.begin(), input.end());
  auto numOfDigits = numOfBits(max);
  for (int i = 0; i < numOfDigits; i++) {
    long long numOfZero = 0;
    long long numOfOne = 0;
    for (auto e : input) {
      if (isBitSet(e, i)) {
        numOfOne++;
      } else {
        numOfZero++;
      }
    }
    result += numOfZero * numOfOne * (1 << i);
    result %= mode;
  }
  return result;
}
int numOfBits(long n) {
  int count = 0;
  while (n > 0) {
    n /= 2;
    count++;
  }
  return count;
}
bool isBitSet(long d, int ith) { return (d >> ith) % 2 == 1; }
void write(long long result) { printf("%llu\n", result); }
