#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int mod = (int)1e9 + 7;
unsigned long long gcd(unsigned long long a, unsigned long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
unsigned long long lcm(unsigned long long a, unsigned long long b) {
  return a * b / gcd(a, b);
}
unsigned long long modpow(unsigned long long a, unsigned long long b,
                          unsigned long long m) {
  if (b == 0) return 1 % m;
  unsigned long long u = modpow(a, b / 2, m);
  u = (u * u) % m;
  if (b % 2) u = (a * u) % m;
  return u;
}
unsigned long long egcd(unsigned long long a, unsigned long long b, int &x,
                        int &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  int x1, y1, d;
  d = egcd(b, a % b, x1, y1);
  x = y1;
  y = x1 - (a / b) * y1;
  return d;
}
unsigned long long modInv(unsigned long long a, unsigned long long b) {
  int x, y;
  egcd(a, b, x, y);
  return (x % b + b) % b;
}
unsigned long long ncr(unsigned long long n, unsigned long long r) {
  if (n - r < r) r = n - r;
  unsigned long long ans = 1;
  unsigned long long fr = 1;
  for (int i = 1, j = n; i <= r; i++, j--) {
    ans = ((ans % mod) * (j % mod)) % mod;
    fr = (fr * i) % mod;
  }
  return ans * modpow(fr, mod - 2, mod) % mod;
}
void solve() {
  unsigned long long n;
  cin >> n;
  unsigned long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  unsigned long long digit = *max_element(a, a + n);
  digit = log2(digit) + 1;
  unsigned long long one[n][digit], zero[n][digit];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < digit; j++) one[i][j] = zero[i][j] = 0;
  }
  for (int i = 0; i < digit; i++) {
    if (a[n - 1] & (1 << i))
      one[n - 1][i] = 1;
    else
      zero[n - 1][i] = 1;
  }
  for (int i = n - 2; i > 0; i--) {
    for (int j = 0; j < digit; j++) {
      one[i][j] = one[i + 1][j];
      zero[i][j] = zero[i + 1][j];
      if (a[i] & (1 << j))
        one[i][j]++;
      else
        zero[i][j]++;
    }
  }
  unsigned long long ans = 0;
  for (int i = 0; i < n - 1; i++) {
    unsigned long long re;
    for (int j = 0; j < digit; j++) {
      if (a[i] & (1 << j)) {
        re = (zero[i + 1][j] % mod * ((1 << j) % mod)) % mod;
      } else {
        re = (one[i + 1][j] % mod * ((1 << j) % mod)) % mod;
      }
      ans = (re + ans) % mod;
    }
  }
  cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ;
  int t = 1;
  while (t--) {
    solve();
  }
}
