#include <bits/stdc++.h>
template <long long int MODVALUE>
class modllint {
  long long int val;
  inline void mod() {
    while (this->val < 0) this->val += MODVALUE;
    this->val %= MODVALUE;
  }
  inline void assign(const long long int val) {
    this->val = val;
    mod();
  }

 public:
  modllint() : val(0){};
  modllint(const long long int val) { assign(val); };
  modllint& operator+=(const long long int val) {
    this->assign(this->val + val);
    return *this;
  }
  modllint& operator+=(const modllint& obj) {
    this->assign(this->val + obj.val);
    return *this;
  }
  modllint& operator-=(const long long int val) {
    this->assign(this->val - val);
    return *this;
  }
  modllint& operator-=(const modllint& obj) {
    this->assign(this->val - obj.val);
    return *this;
  }
  modllint& operator/=(modllint& val) {
    long long int exp = MODVALUE - 2;
    while (exp) {
      if (exp % 2) {
        *this *= val;
      }
      val *= val;
      exp /= 2;
    }
    return *this;
  }
  modllint operator+(const long long int val) { return this += val; }
  modllint operator+(const modllint& obj) { return this += obj; }
  modllint& operator*=(const long long int val) {
    this->assign(this->val * val);
    return *this;
  }
  modllint& operator*=(const modllint& obj) {
    this->assign(this->val * obj.val);
    return *this;
  }
  modllint operator*(const long long int val) { return this *= val; }
  modllint operator*(const modllint& obj) { return this *= obj; }
  modllint& operator=(const modllint& obj) {
    assign(obj.val);
    return *this;
  }
  modllint& operator=(const long long int intvalue) {
    assign(intvalue);
    return *this;
  }
  friend std::ostream& operator<<(std::ostream& os,
                                  const modllint<MODVALUE>& val) {
    os << val.val;
    return os;
  }
  friend std::istream& operator>>(std::istream& is, modllint<MODVALUE>& val) {
    is >> val.val;
    return is;
  }
};
int main(void) {
  int n;
  std::cin >> n;
  std::vector<long long int> A(n);
  modllint<1000000007> ret = 0;
  for (int i = 0; i < n; i++) {
    std::cin >> A[i];
    ret += A[i];
  }
  ret *= n * 2;
  for (int i = 0; i < n; i++) {
    ret -= 2 * A[i];
  }
  modllint<1000000007> two = 2;
  ret /= two;
  std::vector<long long int> bit_count(64, 0);
  for (int j = 0; j < 64; j++) {
    for (int i = 0; i < n; i++) {
      if ((A[i] >> j) & 1) bit_count[j]++;
    }
  }
  for (int j = 0; j < 64; j++) {
    if (bit_count[j] == 0) continue;
    modllint<1000000007> val = 1;
    val *= bit_count[j] * (bit_count[j] - 1);
    val *= 1 << j;
    ret -= val;
  }
  std::cout << ret << std::endl;
  return 0;
}
