#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
template <class T>
void umin(T &a, T b) {
  a = min(a, b);
}
template <class T>
void umax(T &a, T b) {
  a = max(a, b);
}
const int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};
const int dy[] = {0, 1, 0, -1, -1, 1, -1, 1};
const int inf = 1e9, mod = 1e9 + 7, N = 1e3 + 5;
void solve() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  map<int, int> cnt;
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 60; ++j) {
      if (a[i] & (1LL << j)) {
        ans += ((i - cnt[j]) * (1LL << j)) % mod;
        cnt[j]++;
      } else {
        ans += (cnt[j] * (1LL << j)) % mod;
      }
      ans %= mod;
    }
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T = 1;
  while (T--) solve();
}
