#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;
int dp[61];
int main() {
  int N;
  cin >> N;
  ll ans = 0;
  for (int(i) = 0; (i) < (N); (i)++) {
    ll a;
    cin >> a;
    for (int(i) = 0; (i) < (61); (i)++) {
      if (a & ((ll)1 << i)) {
        dp[i]++;
      }
    }
    ans += a * (N - 1);
    ans %= MOD;
  }
  for (int(i) = 0; (i) < (61); (i)++) {
    if (dp[i] >= 2) {
      ans -= (2 << i) * (dp[i] - 1) * dp[i] / 2;
    }
    ans += MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}
