#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
  ll n;
  cin>>n;
  vll a(n);
  vll b1(60);
  vll c(60);
  rep(i,n){
    cin>>a[i];
    ll h=a[i];
    bitset<60> g(a[i]);
    rep(j,60){
      if(h==0) break;
      if(g.test(j)){
        b1[j]++;
      }
      else{
        c[j]++;x
      }
      h/=2;
    }
  }
  sort(rall(a));
  ll ans=0;
  rep(i,n-1){
    ll h=a[i];
    bitset<60> g(a[i]);
    ll cu=59;
    while(1){
      if(g.test(cu)) break;
      cu--;
    }
    ll s=modpow(2,cu,INF);
    for(int j=cu;j>=0;j--){
      if(g.test(j)){
        ans+=s*(n-i-b1[j]);
        s/=2;
        b1[j]--;
        ans%=MOD;
      }
      else{
        ans+=s*(b1[j]);
        s/=2;
        ans%=MOD;
      }
    }
  }
  COUT(ans);
}