#include <bits/stdc++.h>
using namespace std;
long long bigmod(long long a, long long p, long long m) {
  if (p == 0) return 1;
  if (p & 1) {
    long long p1 = a % m;
    long long p2 = bigmod(a, p - 1, m);
    return (p1 * p2) % m;
  }
  long long p1 = bigmod(a, p / 2, m);
  return (p1 * p1) % m;
}
inline void solve() {
  vector<long long> bit(61, 0);
  long long n, sum = 0LL;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    for (long long j = 0; j < 60; j++) {
      if ((a[i] >> j) & 1) bit[j]++;
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 60; j++) {
      if (((a[i] >> j) & 1)) {
        sum += (n - i - bit[j]) * bigmod(2, j, (long long)1000000007);
        bit[j]--;
      }
      if ((((a[i] >> j) & 1) == 0) and (bit[j] > 0)) {
        sum += (bit[j] * bigmod(2, j, (long long)1000000007));
      }
    }
    sum = sum % (long long)1000000007;
  }
  printf("%lld\n", sum);
}
signed main() {
  long long n = 1;
  while (n--) solve();
  return 0;
}
