#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <stack>
#include <cstdint>
typedef long long int llint;

template <std::uint_fast64_t Modulus> class modint {

public:
  llint a;

  constexpr modint(const llint x = 0) noexcept : a(x % Modulus) {}
  constexpr llint &value() noexcept { return a; }
  constexpr const llint &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    llint exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
	*this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};


int main(void){
  int n;
  std::cin >> n;

  std::vector<llint> A(n);
  modint<1000000007> ret = 0;
  for(int i=0; i<n; i++){
    std::cin >> A[i];
    ret += A[i];
  }
  //std::cout << ret << std::endl;
  ret *= n * 2;
  for(int i=0; i<n; i++){
    ret -= 2*A[i];
  }
  //std::cout << "a " << ret << std::endl;
  ret /= 2;
  //std::cout << ret << std::endl;

  std::vector<llint> bit_count(64, 0);
  for(int j=0; j<64; j++){
    for(int i=0; i<n; i++){
      if((A[i]>>j) % 2) bit_count[j]++;
    }
  }

  for(int j=0; j<64;j++){
    if(bit_count[j] == 0) continue;
    modint<1000000007> val = bit_count[j] * (bit_count[j]-1);
    modint<1000000007> hoge = (1<<j);
    val *= hoge;
    ret -= val;
  }
  
  std::cout << ret.a << std::endl;

  return 0;
}
