#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};
const int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
bool cmp(int X, int Y) { return X > Y; }
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
long long modpow(long long a, long long b, long long m = MOD) {
  a %= m;
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % m;
    a = (a * a) % m;
    b >>= 1;
  }
  return res;
}
long long bpow(long long a, long long b) {
  if (b < 0) {
    return 0;
  }
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
long long modinv(long long a, long long m = MOD) { return modpow(a, m - 2, m); }
const int N = 200001;
vector<int> adj[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long ans = 0;
  for (long long i = 0; i < 60; i++) {
    vector<long long> one(n + 1, 0);
    vector<long long> zero(n + 1, 0);
    for (long long j = n - 1; j >= 0; j--) {
      if (a[j] & (1ULL << i)) {
        one[j] = one[j + 1] + 1;
        zero[j] = zero[j + 1];
      } else {
        one[j] = one[j + 1];
        zero[j] = zero[j + 1] + 1;
      }
    }
    long long cnt = 0;
    for (long long j = 0; j < n - 1; j++) {
      if (a[j] & (1ULL << i)) {
        cnt += zero[j + 1];
      } else {
        cnt += one[j + 1];
      }
    }
    long long x = modpow(2, i, MOD);
    long long y = (cnt * x);
    y = (y + MOD) % MOD;
    ans += y;
    ans = (ans + MOD) % MOD;
  }
  cout << ans;
}
