#include <bits/stdc++.h>
using namespace std;
mt19937 mrand(random_device{}());
const long long mod = 1000000007;
int rnd(int x) { return mrand() % x; }
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long modInverse(long long a) {
  long long p = mod - 2;
  return powmod(a, p);
}
const long long MAX_BIT = 60;
int main() {
  int n;
  cin >> n;
  vector<long long> arr(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  vector<int> cnt(MAX_BIT);
  long long ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    for (long long j = 0; j < MAX_BIT; j++) {
      if ((((long long)1 << j) & arr[i])) {
        ans += (((long long)1 << j)) * ((long long)(n - 1 - i - cnt[j]));
        ans %= mod;
      } else {
        ans += (((long long)1 << j)) * ((long long)cnt[j]);
        ans %= mod;
      }
    }
    for (long long j = 0; j < MAX_BIT; j++) {
      if ((((long long)1 << j) & arr[i])) cnt[j]++;
    }
  }
  cout << ans << "\n";
}
