#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (auto& e : a) cin >> e;
  sort(a.begin(), a.end());
  long long sum = 0;
  int cnt[60] = {};
  for (int i = 0; i < n; ++i) {
    (sum += (n - 1) * a[i]) %= 1000000007;
  }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 60; ++j)
      if (a[i] & (1LL << j)) cnt[j]++;
  long long mul = 1;
  for (int i = 0; i < 60; ++i) {
    if (cnt[i] > 1)
      sum -= (((mul * (cnt[i] - 1)) % 1000000007) * 2) % 1000000007;
    sum = (sum % 1000000007 + 1000000007) % 1000000007;
    (mul *= 2) %= 1000000007;
  }
  cout << sum << endl;
  return 0;
}
