#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using ll = long long;
class mod_ll {
 public:
  ll m_v;
  static const ll m_m = 1000000007;
  mod_ll(ll v = 0) : m_v(v) {}
  mod_ll operator=(ll rhs) {
    m_v = rhs % m_m;
    return *this;
  }
  ll operator()() { return m_v; }
  mod_ll operator=(mod_ll rhs) {
    m_v = rhs.m_v;
    return *this;
  }
  mod_ll operator+=(ll rhs) {
    m_v = (m_v + rhs) % m_m;
    return *this;
  }
  mod_ll operator+=(mod_ll rhs) {
    m_v = (m_v + rhs.m_v) % m_m;
    return *this;
  }
  mod_ll operator+(mod_ll rhs) {
    auto ret = *this;
    return ret += rhs;
  }
  mod_ll operator-=(mod_ll rhs) {
    m_v = (m_v - rhs.m_v + m_m) % m_m;
    return *this;
  }
  mod_ll operator-(mod_ll rhs) {
    auto ret = *this;
    return ret -= rhs;
  }
  mod_ll operator*=(ll rhs) {
    m_v = (m_v * (rhs % m_m)) % m_m;
    return *this;
  }
  mod_ll operator*=(mod_ll rhs) {
    m_v = (m_v * rhs.m_v) % m_m;
    return *this;
  }
  mod_ll operator*(mod_ll rhs) {
    mod_ll ret = *this;
    return ret *= rhs;
  }
  mod_ll operator^(ll rhs) {
    mod_ll t = *this;
    mod_ll ret(1LL);
    for (; rhs > 0; rhs >>= 1) {
      if (rhs & 1) ret *= t;
      t *= t;
    }
    return ret;
  }
  mod_ll operator/=(mod_ll rhs) { return *this *= (rhs ^ (m_m - 2)); }
  mod_ll operator/=(ll rhs) {
    mod_ll t(rhs);
    return *this /= t;
  }
  mod_ll operator/(mod_ll rhs) {
    mod_ll ret = *this;
    return ret /= rhs;
  }
};
mod_ll mod_fact(int n) {
  static vector<mod_ll> memo(1);
  if ((int)memo.size() <= n) {
    if (memo.size() == 1) {
      memo[0] = 1;
    }
    for (int i = memo.size(); i <= n; i++) {
      memo.push_back(memo.back() * i);
    }
  }
  return memo[n];
}
mod_ll mod_nCr(int n, int r) {
  mod_ll bunsi = mod_fact(n);
  mod_ll bunbo = mod_fact(n - r) * mod_fact(r);
  return bunsi / bunbo;
}
mod_ll mod_nCr2(int n, int r) {
  mod_ll bunsi(1);
  mod_ll bunbo(1);
  if (r * 2 > n) r = n - r;
  for (int i = 0; i < r; i++) {
    bunsi *= (n - i);
    bunbo *= (i + 1);
  }
  return bunsi / bunbo;
}
mod_ll mod_nPr(int n, int r) {
  mod_ll ret(1);
  for (int i = 0; i < r; i++) {
    ret *= (n - i);
  }
  return ret;
}
struct solve {
  int n;
  vll& a;
  solve(int n, vll& a) : n(n), a(a) {}
  ll operator()() {
    vll c(64);
    for (int i = 0; i < n; i++) {
      ll v = a[i];
      for (int j = 0; j < c.size(); j++) {
        if (v & 1) c[j]++;
        v >>= 1;
      }
    }
    mod_ll ans;
    mod_ll u(1);
    for (int i = 0; i < c.size(); i++) {
      ans += u * (c[i] * (n - c[i]));
      u *= 2;
    }
    return ans();
  }
};
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  for (;;) {
    int n;
    cin >> n;
    if (cin.fail()) break;
    vll a(n);
    for (auto& m : a) cin >> m;
    cout << solve(n, a)() << "\n";
  }
  return 0;
}
