#include <bits/stdc++.h>
using namespace std;
const long long maxn = 3e5 + 10;
const long long mod = 1e9 + 7;
long long a[maxn], b[maxn], n, sum;
inline long long read() {
  long long s = 0, t = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') t = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return s * t;
}
signed main(void) {
  n = read();
  for (long long i = 1; i <= n; i++) a[i] = read();
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j < 60; j++) {
      if (a[i] >> j & 1) {
        b[j]++;
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j < 60; j++) {
      if (a[i] >> j & 1) {
        b[j]--;
      }
    }
    for (long long j = 0; j < 60; j++) {
      if (a[i] >> j & 1) {
        sum = (sum + (n - b[j] - i) % mod * (1LL << j) % mod) % mod;
      } else {
        sum = (sum + b[j] % mod * (1LL << j) % mod) % mod;
      }
    }
  }
  cout << sum << endl;
  return 0;
}
