#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

constexpr ll MOD = 1000000007;

int main() {
  ll n;
  cin >> n;
  ll a;

  vector<ll> one(60);
  rep(i, 0, n) {
    cin >> a;
    rep(j, 0, 60) if (a >> j & 1) one[j]++;
  }

  ll ans = 0;
  rep(i, 0, 60) ans =
    (ans + (1ll << i) % MOD * one[i] % MOD * (n - one[i]) % MOD) % MOD;

  cout << ans << endl;
  return 0;
}

#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int n;
int cnt = 62;
vector<ll> vec;
ll mod = 1e9+7;

ll solve() {
  vector<vector<int>> sum_zero(n+1, vector<int>(cnt, 0));
  vector<vector<int>> sum_one(n+1, vector<int>(cnt, 0));

  ll ans = 0;
  reps(i, 1, n+1) {
    rep(j,cnt) {
      if (vec.at(i-1) >> j & 1ll) {
        sum_one.at(i).at(j) = sum_one.at(i-1).at(j) + 1;
        sum_zero.at(i).at(j) = sum_zero.at(i-1).at(j);
      } else {
        sum_one.at(i).at(j) = sum_one.at(i-1).at(j);
        sum_zero.at(i).at(j) = sum_zero.at(i-1).at(j) + 1;
      }
    }
  }
  rep(i, n-1) {
    ll t = 1;
    rep(j, cnt) {
      ll v;
      if (vec.at(i) >> j & 1ll) {
        v = (sum_zero.at(n).at(j) - sum_zero.at(i+1).at(j));
      } else {
        v = (sum_one.at(n).at(j) - sum_one.at(i+1).at(j));
      }
      ans += v * t;
      ans %= mod;
      t *= 2;
      t %= mod;
    }
  }
  return ans;
}

int main()
{ 
  cin >> n;
  vec.resize(n);
  rep(i, n) cin >> vec.at(i);
  cout << solve() << endl;
  
  return 0;
}