#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const int INF = 2000000000;
const long long LINF = 2000000000000000000;
template <typename T>
void print(vector<T>& a) {
  for (int i = 0; i < a.size(); i++) cout << a[i] << ' ';
  cout << '\n';
}
template <typename T>
void print(deque<T>& a) {
  for (int i = 0; i < a.size(); i++) cout << a[i] << ' ';
  cout << '\n';
}
template <typename T>
void print(vector<vector<T>>& a) {
  for (int i = 0; i < a.size(); i++) {
    for (int j = 0; j < a[i].size(); j++) cout << a[i][j] << ' ';
    cout << '\n';
  }
}
template <typename T>
void input(vector<T>& a) {
  for (int i = 0; i < a.size(); i++) cin >> a[i];
}
template <typename T>
void input(deque<T>& a) {
  for (int i = 0; i < a.size(); i++) cin >> a[i];
}
template <typename T>
void input(vector<vector<T>>& a) {
  for (int i = 0; i < a.size(); i++)
    for (int j = 0; j < a[i].size(); j++) cin >> a[i][j];
}
const long long mod = 1e9 + 7;
void solve() {
  int n;
  cin >> n;
  vector<long long> a(n);
  input(a);
  long long ans = 0;
  vector<long long> cnt1(60);
  vector<long long> cnt0(60);
  for (auto to : a) {
    for (int i = 0; i < 60; i++)
      if (to & (long long(1) << i))
        cnt1[i]++;
      else
        cnt0[i]++;
  }
  for (int i = 0; i < n; i++) {
    for (int bit = 0; bit < 60; bit++) {
      if (a[i] & (long long(1) << bit)) {
        cnt1[bit]--;
        ans = (ans % mod + (cnt0[bit]) % mod * (long long(1) << bit) % mod);
        ans = ans % mod;
      } else {
        cnt0[bit]--;
        ans =
            (ans % mod + (cnt1[bit] % mod) * (long long(1) << bit) % mod) % mod;
      }
    }
  }
  cout << ans % mod;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tst = 1;
  while (tst--) solve();
}
