#include <bits/stdc++.h>
using namespace std;
int g_bm = 1000000007;
int modl(long long a) {
  a %= g_bm;
  if (a < 0) a += g_bm * (1 - (a + 1) / g_bm);
  return a;
}
int modadd(long long a, long long b) { return modl(modl(a) + modl(b)); }
int modminus(long long a, long long b) { return modl(modl(a) - modl(b)); }
int modmul(long long a, long long b) { return modl(modl(a) * modl(b)); }
int modpow(long long a, long long b) {
  int prebit = modl(a);
  int ans = 1;
  for (int bit = 0; (long unsigned int)b >= (1UL << bit); bit++) {
    if (bit > 0) prebit = modmul(prebit, prebit);
    if (b & (1UL << bit)) ans = modmul(ans, prebit);
  }
  return ans;
}
int modcalcsub(long long a, long long b, char c) {
  switch (c) {
    case '+':
      return modadd(a, b);
    case '-':
      return modminus(a, b);
    case '*':
      return modmul(a, b);
  }
  return 0;
}
int modsublevel(char c) {
  switch (c) {
    case '+':
    case '-':
      return 0;
    case '*':
      return 1;
  }
  return 0;
}
int modinv(long long a) {
  long long b = g_bm, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  return modl(u);
}
int modcalc(long long a1, char c1, long long a2, char c2 = 0, long long a3 = 0,
            char c3 = 0, long long a4 = 0, char c4 = 0, long long a5 = 0,
            char c5 = 0, long long a6 = 0, char c6 = 0, long long a7 = 0,
            char c7 = 0) {
  char c[8] = {c1, c2, c3, c4, c5, c6, c7, '0'};
  long long a[8] = {a1, a2, a3, a4, a5, a6, a7, 0};
  int ans[4];
  char prec[4];
  int level = 0;
  int index = 0;
  ans[0] = 0;
  prec[0] = '+';
  while (prec[level] != '\0') {
    int nlevel = modsublevel(c[index]);
    while (level < nlevel) {
      ans[level + 1] = 0;
      prec[level + 1] = '+';
      level++;
    }
    ans[level] = modcalcsub(ans[level], a[index], prec[level]);
    while (nlevel < level) {
      ans[level - 1] = modcalcsub(ans[level - 1], ans[level], prec[level - 1]);
      level--;
    }
    prec[level] = c[index++];
  }
  return ans[0];
}
void addbitsum(long long a, int *s0, int *s1, int d) {
  for (int k = 0; k < 60; k++) {
    if (a & (1LL << k)) {
      s1[k] += d;
    } else {
      s0[k] += d;
    }
  }
}
int main() {
  int n;
  cin >> n;
  long long *a = new long long[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int sumj0[64];
  int sumj1[64];
  for (int k = 0; k < 64; k++) sumj0[k] = 0, sumj1[k] = 0;
  for (int j = 0; j < n; j++) addbitsum(a[j], sumj0, sumj1, 1);
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    addbitsum(a[i], sumj0, sumj1, -1);
    long long bitpow = 1;
    for (int k = 0; k < 60; k++) {
      int tmp = (a[i] & (1LL << k)) ? sumj0[k] : sumj1[k];
      ans = modcalc(ans, '+', tmp, '*', bitpow);
      bitpow = (bitpow << 1);
    }
  }
  cout << ans << endl;
}
