#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    rep(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    rep(i,V){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};
int main(){
  ll n; cin>>n;
  ll a[n]={};
  ll b[65]={};
  rep(i,n){
    cin>>a[i];}
  ll ans = 0;
  rep(i,n){
    bitset<61> s(a[i]);
    rep(j,61){
      if(s.test(j))b[j]++;}
  }
  ll k = 1;
  rep(i,61){
    ll m = b[i]*(n-b[i]);
    m%=MOD;
    ans += m*k;
    k*=2;
    k%=MOD;
  ans%=MOD;}
  cout << ans << endl;}

#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
using P = pair<int, int>;

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& v) {
    os << "(" << v.first << ", " << v.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    for (int i = 0; i < v.size(); i++) {
        if (i) os << ", ";
        os << v[i];
    }
    os << "}";
    return os;
}

int main()
{
    ll mod = TEN(9) + 7;
    int n;
    cin >> n;
    vector<ll> a(n, 0);
    ll a_max = 0;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a_max = max(a_max, a[i]);
    }

    ll y = 1; int log_a_max = 0;
    while (y < a_max) {
        y *= 2;
        log_a_max++;
    }

    vector<vector<bool>> p(n, vector<bool>(log_a_max, 0));
    vector<int> s(log_a_max, 0);
    for (int i = 0; i < n; i++) {
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < log_a_max; j++) {
            s[j] += (a[i] >> j) & 1;
        }
    }

    ll sum = 0;
    ll x = 1;
    for (int j = 0; j < log_a_max; j++) {
        for (int i = 0; i < n; i++) {
            if (a[i] >> j & 1) {
                sum += x * (n - s[j]);
            } else {
                sum += x * s[j];
            }
            sum %= mod;
        }
        x *= 2;
        x %= mod;
    }
    cout << sum * ((mod + 1) / 2) % mod << endl;
    return 0;
}
