#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int N = 5e5 + 6;
const int M = 2e6 + 6;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;
bool eq(const double &a, const double &b) { return fabs(a - b) < eps; }
bool ls(const double &a, const double &b) { return a + eps < b; }
bool le(const double &a, const double &b) { return eq(a, b) || ls(a, b); }
long long gcd(long long a, long long b) { return a == 0 ? b : gcd(b % a, a); };
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long kpow(long long a, long long b) {
  long long res = 1;
  a %= mod;
  if (b < 0) return 1;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n;
long long a[N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (n); ++i) scanf("%lld", a + i);
  long long ret = 0;
  for (int i = 0; i < (60); ++i) {
    long long tmp = 1ll << i;
    vector<int> L, R;
    L.clear();
    R.clear();
    for (int j = 0; j < (n); ++j) {
      if ((1ll << i) & a[j])
        R.push_back(j);
      else
        L.push_back(j);
    }
    int l = 0, r = 0;
    int cntL = (int)L.size(), cntR = (int)R.size();
    while (l < cntL && r < cntR) {
      long long cur = 0;
      if (L[l] < R[r]) {
        cur += 1ll * (cntR - r) * tmp;
        l++;
      } else {
        cur += 1ll * (cntL - l) * tmp;
        r++;
      }
      ret += cur;
      ret %= mod;
    }
  }
  printf("%lld\n", ret);
  return 0;
}
