#ifdef LOCAL_BUILD
#include "pch.h"
#define DLOG(msg) cout << "#" << __LINE__ << ":" << msg << endl;
#define DLOG_V(var)\
  cout << "#" << __LINE__ << ":" << #var << " : " << var << endl;
#else
#include <bits/stdc++.h>
#define DLOG(msg)
#define DLOG_V(var)
#endif
using namespace std;

template <typename Iter>
Iter partition(Iter begin, Iter end, Iter pivot) {
  if (distance(pivot, end) != 1) {
    iter_swap(end -1, pivot);
    pivot = end - 1;
  }
  auto x = end;
  for (auto it = begin; it != end; ++it) {
    if (it != pivot && *it <= *pivot) {
      x = (x == end) ? begin : x + 1;
      if (x != it) {
        iter_swap(x, it);
      }
    }
  }
  x = (x == end) ? begin : x + 1;
  iter_swap(x, pivot);
  return x;
}

int main() {
  int n;
  cin >> n;
  vector<int> nums;
  for (int t, i = 0; i < n; ++i) {
    cin >> t;
    nums.push_back(t);
  }
  auto pivot = partition(nums.begin(), nums.end(), nums.end() - 1);
  bool first = true;
  for (auto it = nums.begin(); it != nums.end(); ++it) {
    if (!first)
      cout << " ";
    first = false;
    bool is_pivot = it == pivot;
    if (is_pivot)
      cout << "[";
    cout << *it;
    if (is_pivot)
      cout << "]";
  }
  cout << endl;
}
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
using PL = pair<ll, ll> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define mod 1000000007

int modpow(ll a, ll n){
    if(n == 0) return 1 ;
    if(n == 1) return a % mod ;
    if(n % 2) return (a * modpow(a, n-1))%mod ;
    ll t = modpow(a, n/2) ;
    return (t*t) % mod ;
}

int main() {
    ll n ;
    cin >> n ;
    vector<ll> a (n) ;
    vector<ll> c (60) ;
    rep(i, n) {
        cin >> a[i] ;
        rep(j, 60){
            if(a[i] >> j & 1){
                c[j]++ ;
            }
        }
    }
    ll ans = 0 ;
    ll k =  n;
    rep(i, n){
        rep(j, 60){
            if(a[i] >> j & 1){
                ans += modpow(2,j)*(k - c[j]) ;
                ans %= mod ;
                c[j]-- ;
            }
            else {
                ans += modpow(2,j)*c[j] ;
            }
        }
        k-- ;
    }
    cout << ans << endl ;
} 