#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
long long pows(long long b, long long e) {
  if (e == 0)
    return 1;
  else if (e % 2 == 0) {
    long long a = pow(b, e / 2);
    return a * a;
  } else {
    long long a = pow(b, e / 2);
    return b * a * a;
  }
}
long long powm(long long x, long long y, long long m) {
  x = x % m;
  long long res = 1;
  while (y) {
    if (y & 1) res = res * x;
    res %= m;
    y = y >> 1;
    x = x * x;
    x %= m;
  }
  return res;
}
long long modInverse(long long a, long long m = 1000000007) {
  if (m == 1) return 0;
  long long m0 = m, y = 0, x = 1;
  while (a > 1) {
    long long q = a / m, t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
long long ar[300010];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m, i, j, k, x, y, z, e, f, p, q, g, l, r, w, h,
      count1 = 0, prod = 1, a, b, c, d, index, x1, x2, diff, ans = 0, sum = 0,
      sum1 = 0, sum2 = 0, flag = 0, flag1 = 0, flag2 = 0;
  string s, s1, s2;
  cin >> n;
  vector<long long> set1[60], unset[60];
  long long power[60];
  p = 1;
  for (i = 0; i < 60; i++) {
    power[i] = p;
    p *= 2;
    p %= 1000000007;
  }
  for (i = 0; i < n; i++) {
    cin >> ar[i];
    for (j = 0; j < 60; j++) {
      if ((ar[i] >> j) & 1) {
        set1[j].push_back(i);
      } else {
        unset[j].push_back(i);
      }
    }
  }
  vector<pair<long long, long long>> v;
  for (i = 0; i < 60; i++) {
    p = set1[i].size();
    q = unset[i].size();
    v.push_back(make_pair(p, q));
  }
  long long t1[60] = {0}, t2[60] = {0};
  for (i = 0; i < n; i++) {
    for (j = 0; j < 60; j++) {
      if ((ar[i] >> j) & 1) {
        t1[j]++;
        p = v[j].second - t2[j];
        p = p * power[j];
        p %= 1000000007;
        ans += p;
        ans %= 1000000007;
      } else {
        t2[j]++;
        p = v[j].first - t1[j];
        p = p * power[j];
        p %= 1000000007;
        ans += p;
        ans %= 1000000007;
      }
    }
  }
  cout << ans;
}
