#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
static inline void amin(T &x, U y) {
  if (x > y) x = y;
}
template <typename T, typename U>
static inline void amax(T &x, U y) {
  if (x < y) x = y;
}
int inf = 2e9 + 15;
long long INF = 2e18L + 15;
const long long mod = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  long long x;
  vector<long long> pref(64, 0);
  vector<long long> one(64, 0);
  for (int i = 0; i < n; ++i) {
    cin >> x;
    for (int j = 0; j < 62; ++j) {
      if (x & (1ll << j)) {
        one[j] += ((long long)i - pref[j]);
      } else {
        one[j] += pref[j];
      }
    }
    for (int j = 0; j < 62; ++j) {
      if (x & (1ll << j)) {
        pref[j]++;
      }
    }
  }
  long long pow = 1;
  long long ans = 0;
  for (int i = 0; i < 62; ++i) {
    ans += one[i] * pow;
    ans %= mod;
    pow *= 2;
  }
  cout << ans << endl;
  return 0;
}
