#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const int MAX = 510000;
const double pi = acos(-1);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
long long modpow(long long a, long long n) {
  if (n == 0) return 1;
  if (n % 2 == 0) {
    long long t = modpow(a, n / 2);
    return t * t % MOD;
  }
  return a * modpow(a, n - 1) % MOD;
}
long long modinv(long long a) { return modpow(a, MOD - 2); }
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct UnionFind {
  vector<int> par;
  vector<int> rank;
  UnionFind(int n = 1) { init(n); }
  void init(int n = 1) {
    par.resize(n);
    rank.resize(n);
    for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
  }
  int root(int x) {
    if (par[x] == x) {
      return x;
    } else {
      int r = root(par[x]);
      return par[x] = r;
    }
  }
  bool issame(int x, int y) { return root(x) == root(y); }
  bool merge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (rank[x] < rank[y]) swap(x, y);
    if (rank[x] == rank[y]) ++rank[x];
    par[y] = x;
    return true;
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  COMinit();
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < (long long)(n); i++) cin >> a[i];
  vector<vector<long long>> cnt(n, vector<long long>(60, 0));
  for (long long i = 0; i < n - 1; i++) {
    for (long long j = 0; j < (long long)(60); j++) {
      if (a[n - 1 - i] & (1ll << j))
        cnt[i + 1][j] = cnt[i][j] + 1;
      else
        cnt[i + 1][j] = cnt[i][j];
    }
  }
  long long ans = 0;
  for (long long i = 0; i < (long long)(n - 1); i++) {
    for (long long j = 0; j < (long long)(60); j++) {
      if (!((a[i] & (1ll << j)))) {
        ans += (1ll << j) * cnt[n - 1 - i][j];
        ans %= MOD;
      } else {
        ans += (long long)(1ll << j) * (n - 1 - i - cnt[n - 1 - i][j]);
        ans %= MOD;
      }
    }
  }
  cout << ans << endl;
}
